I have a situation where in a certain condition, I want whatever jQuery ready handlers have been bound not to actually fire on the DOMContentReady event. These handlers are bound in various places, including various include files, plugins and so on. So while I could set some kind of global variable in a script near the top of my page, and put an if condition to check for this variable in front of every $(document).ready() binding, I’d rather not.
Ideally I’m looking for one of two things,
- a property I could set on the jQuery object before the includes that would tell it to ignore calls to
.ready() - a method I could call towards the end of the document, in an inline script before
DOMContentReadyhas fired, to unbind theready()handlers.
The obvious one, $(document).unbind('ready') doesn’t do it, I guess because .ready() isn’t an ordinary event binding.
Can this be done? If so, how?
One vague idea I had would be to extend the jQuery prototype, and replace ready() with a method that would check a new property that I would introduce. Does that make sense?
you should use holdready