Using jQuery, is there a way to retrigger the document.ready
trigger at some point after a page has loaded?
Update: jQuery sheds them once they are run.
In some cases you need to add more code (scripts) in another places of the code, so creating a function limit you to write all the code in the same area. This why I prefer to add my custom events, and then trigger them:
//Add a page Ready custom event
$( document ).on( "page.ready", function( event ) {
//Your Ready Scripts
});
//Add a page Load custom event
$( document ).on( "page.load", function( event ) {
//Your Load Scripts
});
//Trigger Ready scripts on page ready
jQuery(function($) {
$( document ).trigger( "page.ready" );
});
//Trigger Load scripts on page load
$(window).load(function () {
$( document ).trigger( "page.load" );
});
//Trigger the Custom events manually
$( document ).trigger( "page.ready" );
$( document ).trigger( "page.load" );
https://learn.jquery.com/events/introduction-to-custom-events/