tags:

views:

886

answers:

5

Using jQuery, is there a way to retrigger the document.ready trgger at some point after a page has loaded?

update: jQuery sheds them once they are run. In my experiments it looks like jQuery will run a ().ready callback as soon as it is encountered once the initial ready event is triggered.

+1  A: 

Aaron - what would you be trying to accomplish, reinitializing variables?

Edited... The beauty of jQuery in my opinion is the call back functions. Why not just have some action/function executed after the event.

RSolberg
A: 

You should be able to with document.ready.apply();

+6  A: 
Matthew Crumley
+1 for calling it directly
Kiv
A: 

I can see one scenario where this would be very useful, that is if you delay loading jQuery until everything else has loaded, then you dynamically append a new script element to load jQuery.

In this case, $(document).ready is not always triggered, since in many cases the document will have completely loaded before jQuery is done loading and has set up the right event handlers.

You could use named functions and call those instead, but it would still break any plugin that relies on $(document).ready.

Steadicat
A: 

ASP.Net UpdatePanel partial page loads are another place where one might want to re-trigger loading functionality - not that $().ready is the right place to do that. In that case, you can either use page_load or the MS framework's endrequest event.

DDaviesBrackett