Remy
Remy

Reputation: 12703

Define sequence of document.ready() functions?

In the old jquery one could add a function to the top of document.ready like this:

$.readyList.unshift(function () {

Now this is not possible anymore. Is there another way to move one function to the top? Our ASP.NET pages consist of different controls that all have their own document.ready, so it is currently impossible for me to change this. But I need one function to run before all others.

Is there another "clean" way to do this?

Upvotes: 4

Views: 420

Answers (2)

loxxy
loxxy

Reputation: 13151

from here:

It's due to the fact that ready is (and should be) an event - the fact that some of the internals were exposed was a mistake (one that we're working to rectify). As you mentioned it was undocumented and its exposure was unintended.

Though I'm not sure what prevents you from writing your own list (or extend jquery) with a new readyList:

var readyList = [func1, func2, func3 ...];

and executing it one by one in .ready():

Upvotes: 4

raam86
raam86

Reputation: 6871

Use holdready.

from jQuery:

$.holdReady(true);
//your function that must be first...
$.holdReady(false);

Upvotes: 3

Related Questions