Skip to content

Commit 0d78b3a

Browse files
Connor CartwrightAurelioDeRosa
authored andcommitted
one: Clarified its behavior
Fixes gh-796 Closes gh-923
1 parent 8b3b088 commit 0d78b3a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

entries/one.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</argument>
4545
</signature>
4646
<longdesc>
47-
<p>The <code>.one()</code> method is identical to <code>.on()</code>, except that the handler is unbound after its first invocation. For example:</p>
47+
<p>The <code>.one()</code> method is identical to <code>.on()</code>, except that the handler for a given element and event type is unbound after its first invocation. For example:</p>
4848
<pre><code>
4949
$( "#foo" ).one( "click", function() {
5050
alert( "This will be displayed only once." );
@@ -59,6 +59,12 @@ $( "#foo" ).on( "click", function( event ) {
5959
</code></pre>
6060
<p>In other words, explicitly calling <code>.off()</code> from within a regularly-bound handler has exactly the same effect.</p>
6161
<p>If the first argument contains more than one space-separated event types, the event handler is called <em>once for each event type</em>.</p>
62+
<pre><code>
63+
$( "#foo" ).one( "click mouseover", function() {
64+
alert( "The " + event.type + " event happened!" );
65+
});
66+
</code></pre>
67+
<p>In the example above the alert could be displayed twice due to the <em>two</em> event types (<code>click</code> and <code>mouseover</code>).</p>
6268
</longdesc>
6369
<example>
6470
<desc>Tie a one-time click to each div.</desc>

0 commit comments

Comments
 (0)