I have an an MVC 2 web application that uses Master pages. In the master pages, there are several ready blocks just like the one below scattered throughout the file
$(document).ready(function () {
...
});
Likewise, many of my views also have multiple ready blocks scattered throughout.
I have been asked to introduce another ready block into the Master that will run last.
My question is “Is there a way to guarantee that this new ready block will run last?”. My thought was that if I put it at the very bottom of the Master page that would do it but I can’t seem to convince myself that this is certain.
This is the jQuery’s
.addmethod that is called to push your$(document).ready()‘s callback to the list of all callbacks:source: jQuery’s callback
So: what it basically does is pushing all the functions inside the
listarray and after the event has been triggered – call them in the same order and if your function has been pushed last – it will be called last.To push it last you can declare it even in the head after including all other
.jsfiles(just make sure that there aren’t any other
$(document).ready()below)