-
Notifications
You must be signed in to change notification settings - Fork 264
/
Copy pathjQuery.holdReady.xml
39 lines (39 loc) · 2.37 KB
/
jQuery.holdReady.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?xml version="1.0"?>
<entry type="method" name="jQuery.holdReady" return="undefined" deprecated="3.2">
<title>jQuery.holdReady()</title>
<desc>Holds or releases the execution of jQuery's ready event.</desc>
<signature>
<added>1.6</added>
<argument name="hold" type="Boolean">
<desc>Indicates whether the ready hold is being requested or released</desc>
</argument>
</signature>
<longdesc>
<div class="warning">
<p>Note: This API has been deprecated in jQuery 3.2. Instead of relying on this global switch, it's better to put explicitly wait for required code. If you need to wait both for the ready state & for a custom promise, use the following pattern:</p>
<code><![CDATA[$.when( $.ready, customPromise )
.then( function() {
// main code
} )
.catch( function( error ) {
// handle errors
} )]]></code>
</div>
<p>The <code>$.holdReady()</code> method allows the caller to delay jQuery's ready event. This <em>advanced feature</em> would typically be used by dynamic script loaders that want to load additional JavaScript such as jQuery plugins before allowing the ready event to occur, even though the DOM may be ready. This method must be called early in the document, such as in the <code><head></code> immediately after the jQuery script tag. Calling this method after the ready event has already fired will have no effect. </p>
<p>To delay the ready event, first call <code>$.holdReady( true )</code>. When the ready event should be released to execute, call <code>$.holdReady( false )</code>. Note that multiple holds can be put on the ready event, one for each <code>$.holdReady( true )</code> call. The ready event will not actually fire until all holds have been released with a corresponding number of <code>$.holdReady( false )</code> calls <em>and</em> the normal document ready conditions are met. (See <a href="/ready/"><code>ready</code></a> for more information.)</p>
</longdesc>
<example>
<desc>Delay the ready event until a custom plugin has loaded.</desc>
<code><![CDATA[
$.holdReady( true );
$.getScript( "myplugin.js", function() {
$.holdReady( false );
});
]]></code>
</example>
<category slug="core"/>
<category slug="properties/global-jquery-object-properties"/>
<category slug="events/document-loading"/>
<category slug="version/1.6"/>
<category slug="deprecated/deprecated-3.2"/>
</entry>