I want to implement the following code in my elgg and this need to be called after the jquery is loaded in elgg.
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.16/datatables.min.js"></script>
<script>
$(function () {
$("#example1").DataTable();
$('#example2').DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false
});
});
</script>
Now as elgg loads all the js and jquery file at the end of the page. I want to execute the above code after the jquery is loaded in elgg. This needs to be implemented only at one specific page at "/mod/plugin_name/views/default/folder_name/view.php"
How can I do this?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- Jerome Bakker@jeabakker
Jerome Bakker - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- Rohit Gupta@Rohit_1990_3676
Rohit Gupta - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
You must log in to post replies.script_init.php
Learn how to write your script part as an AMD module http://learn.elgg.org/en/stable/design/amd.html and http://requirejs.org/docs/whyamd.html
In your module you can require jQuery (and other) module if needed.
@Jerome Bakker That's right. But there're some cases (and dirty some JS) where the old methods works only.
RvR, elgg_register_js and elgg_load_js did the trick but elgg_extend_view is not working as I want. I need the script function to load after the jquery but the elgg_extend_view is loading it before the jquery. Here is screenshot of the page source code.
Then add it in footer:
or directly in 'page\elements\foot.php' overriding this view in your plugin.
All JavaScript works in AMD, so no dirty excuses