Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 768
Remy Avatar asked Mar 23 '23 06:03

Remy


1 Answers

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():

like image 81
loxxy Avatar answered Apr 01 '23 04:04

loxxy