File: index.html

package info (click to toggle)
jqapi 1.7%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 3,288 kB
  • sloc: javascript: 632; makefile: 12
file content (97 lines) | stat: -rw-r--r-- 4,120 bytes parent folder | download | duplicates (2)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html lang='en'><head><meta http-equiv='content-type' content='text/html; charset=UTF-8' /></head><body>
<div class="entry-content">
        <div class="entry-title roundTop">
          
          <h1 class="jq-clearfix">deferred.done()</h1>
          <div class="entry-meta jq-clearfix">
                        Categories:
            <span class="category"><a href="http://api.jquery.com/category/deferred-object/" title="View all posts in Deferred Object">Deferred Object</a></span>
  

          </div>

</div>
<div id="deferred-done1" class="entry method">
<h2 class="jq-clearfix roundTop section-title">
<span class="name">deferred.done( doneCallbacks [, doneCallbacks]  )</span> <span class="returns">Returns: <a class="return" href="http://api.jquery.com/Types/#Deferred">Deferred</a></span>
</h2>
<div class="jq-box roundBottom entry-details">
<p class="desc"><strong>Description: </strong> Add handlers to be called when the Deferred object is resolved. </p>
<ul class="signatures"><li class="signature" id="deferred-done-doneCallbacks-doneCallbacks">
<h4 class="name">
<span class="versionAdded">version added: <a href="/category/version/1.5/">1.5</a></span>deferred.done( doneCallbacks [, doneCallbacks] )</h4>
<p class="arguement"><strong>doneCallbacks</strong>
             A function, or array of functions, that are called when the Deferred is resolved.
           </p>
<p class="arguement"><strong>doneCallbacks</strong>
             Optional additional functions, or arrays of functions, that are called when the Deferred is resolved.
           </p>
</li></ul>
<div class="longdesc"><p>The <code>deferred.done()</code> method accepts one or more arguments, all of which can be either a single function or an array of functions. When the Deferred is resolved, the doneCallbacks are called. Callbacks are executed in the order they were added. Since <code>deferred.done()</code> returns the deferred object, other methods of the deferred object can be chained to this one, including additional <code>.done()</code> methods. When the Deferred is resolved, doneCallbacks are executed using the arguments provided to the <a href="/deferred.resolve/"><code>resolve</code></a> or <a href="/deferred.resolveWith/"><code>resolveWith</code></a> method call in the order they were added. For more information, see the documentation for <a href="/category/deferred-object/">Deferred object</a>.</p></div>
<h3>Examples:</h3>
<div class="entry-examples" id="entry-examples">
<div id="example-0">
<h4>Example: <span class="desc">Since the jQuery.get method returns a jqXHR object, which is derived from a Deferred object, we can attach a success callback using the .done() method.</span>
</h4>
<pre class="prettyprint"><code class="example">
$.get("test.php").done(function() { 
  alert("$.get succeeded"); 
});
</code></pre>
</div>
<div id="example-1">
<h4>Example: <span class="desc">Resolve a Deferred object when the user clicks a button, triggering a number of callback functions:</span>
</h4>
<pre class="prettyprint"><code class="example demo-code">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;script src="http://code.jquery.com/jquery-1.7rc2.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
  
 &lt;button&gt;Go&lt;/button&gt;
 &lt;p&gt;Ready...&lt;/p&gt;

&lt;script&gt;
// 3 functions to call when the Deferred object is resolved
function fn1() {
  $("p").append(" 1 ");
}
function fn2() {
  $("p").append(" 2 ");
}
function fn3(n) {
  $("p").append(n + " 3 " + n);
}

// create a deferred object
var dfd = $.Deferred();

// add handlers to be called when dfd is resolved
dfd
// .done() can take any number of functions or arrays of functions
.done( [fn1, fn2], fn3, [fn2, fn1] )
// we can chain done methods, too
.done(function(n) {
  $("p").append(n + " we're done.");
});

// resolve the Deferred object when the button is clicked
$("button").bind("click", function() {
  dfd.resolve("and");
});
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h4>Demo:</h4>
<div class="demo code-demo"></div>
</div>
</div>
</div>
</div>

        </div>

</body></html>