Skip to content

Commit 86f1bf1

Browse files
committed
jQuery.when: passing no arguments returns a resolved promise
Fixes gh-342 Closes gh-684
1 parent 7163b8c commit 86f1bf1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

entries/jQuery.when.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ $.when( $.ajax( "test.aspx" ) ).then(function( data, textStatus, jqXHR ) {
1919
<pre><code>
2020
$.when( { testing: 123 } ).done(function( x ) {
2121
alert( x.testing ); // Alerts "123"
22+
});
23+
</code></pre>
24+
<p>If you don't pass it any arguments at all, <code>jQuery.when()</code> will return a resolved promise.</p>
25+
<pre><code>
26+
$.when().then(function( x ) {
27+
alert( "I fired immediately" );
2228
});
2329
</code></pre>
2430
<p>In the case where multiple Deferred objects are passed to <code>jQuery.when()</code>, the method returns the Promise from a new "master" Deferred object that tracks the aggregate state of all the Deferreds it has been passed. The method will resolve its master Deferred as soon as all the Deferreds resolve, or reject the master Deferred as soon as one of the Deferreds is rejected. If the master Deferred is resolved, the doneCallbacks for the master Deferred are executed. The arguments passed to the doneCallbacks provide the resolved values for each of the Deferreds, and matches the order the Deferreds were passed to <code>jQuery.when()</code>. For example:</p>

0 commit comments

Comments
 (0)