Skip to content

Commit 0ff4f80

Browse files
jouvekswedberg
authored andcommitted
replace uses of .bind/.unbind with prefered .on/.off
1 parent 547334b commit 0ff4f80

42 files changed

Lines changed: 56 additions & 56 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

entries/blur.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<added>1.0</added>
2222
</signature>
2323
<longdesc>
24-
<p>This method is a shortcut for <code>.bind('blur', handler)</code> in the first two variations, and <code>.trigger('blur')</code> in the third.</p>
24+
<p>This method is a shortcut for <code>.on('blur', handler)</code> in the first two variations, and <code>.trigger('blur')</code> in the third.</p>
2525
<p>The <code>blur</code> event is sent to an element when it loses focus. Originally, this event was only applicable to form elements, such as <code>&lt;input&gt;</code>. In recent browsers, the domain of the event has been extended to include all element types. An element can lose focus via keyboard commands, such as the Tab key, or by mouse clicks elsewhere on the page.</p>
2626
<p>For example, consider the HTML:</p>
2727
<pre><code>&lt;form&gt;

entries/change.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<added>1.0</added>
2222
</signature>
2323
<longdesc>
24-
<p>This method is a shortcut for <code>.bind('change', handler)</code> in the first two variations, and <code>.trigger('change')</code> in the third.</p>
24+
<p>This method is a shortcut for <code>.on('change', handler)</code> in the first two variations, and <code>.trigger('change')</code> in the third.</p>
2525
<p>The <code>change</code> event is sent to an element when its value changes. This event is limited to <code>&lt;input&gt;</code> elements, <code>&lt;textarea&gt;</code> boxes and <code>&lt;select&gt;</code> elements. For select boxes, checkboxes, and radio buttons, the event is fired immediately when the user makes a selection with the mouse, but for the other element types the event is deferred until the element loses focus.</p>
2626
<p>For example, consider the HTML:</p>
2727
<pre><code>&lt;form&gt;

entries/click.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
<added>1.0</added>
2222
</signature>
2323
<longdesc>
24-
<p>In the first two variations, this method is a shortcut for <code>.bind("click", handler)</code>, as well as for <code>.on("click", handler)</code> as of jQuery 1.7. In the third variation, when <code>.click()</code> is called without arguments, it is a shortcut for <code>.trigger("click")</code>. </p>
25-
<p>The <code>click</code> event is sent to an element when the mouse pointer is over the element, and the mouse button is pressed and released. Any HTML element can receive this event.</p>
26-
<pre><code>For example, consider the HTML:
27-
&lt;div id="target"&gt;
24+
<p>This method is a shortcut for <code>.on('click', handler)</code> in the first two variations, and <code>.trigger('click')</code> in the third.
25+
The <code>click</code> event is sent to an element when the mouse pointer is over the element, and the mouse button is pressed and released. Any HTML element can receive this event.
26+
For example, consider the HTML:</p>
27+
<pre><code>&lt;div id="target"&gt;
2828
Click here
2929
&lt;/div&gt;
3030
&lt;div id="other"&gt;

entries/closest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ $('li.item-a').closest('#one', listItemII)
101101
<example>
102102
<desc>Show how event delegation can be done with closest. The closest list element toggles a yellow background when it or its descendent is clicked.</desc>
103103
<code><![CDATA[
104-
$( document ).bind("click", function( e ) {
104+
$( document ).on("click", function( e ) {
105105
$( e.target ).closest("li").toggleClass("hilight");
106106
});
107107
]]></code>
@@ -118,7 +118,7 @@ $('li.item-a').closest('#one', listItemII)
118118
<desc>Pass a jQuery object to closest. The closest list element toggles a yellow background when it or its descendent is clicked.</desc>
119119
<code><![CDATA[
120120
var $listElements = $("li").css("color", "blue");
121-
$( document ).bind("click", function( e ) {
121+
$( document ).on("click", function( e ) {
122122
$( e.target ).closest( $listElements ).toggleClass("hilight");
123123
});
124124
]]></code>

entries/dblclick.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<added>1.0</added>
2222
</signature>
2323
<longdesc>
24-
<p>This method is a shortcut for <code>.bind('dblclick', handler)</code> in the first two variations, and <code>.trigger('dblclick')</code> in the third.
24+
<p>This method is a shortcut for <code>.on('dblclick', handler)</code> in the first two variations, and <code>.trigger('dblclick')</code> in the third.
2525
The <code>dblclick</code> event is sent to an element when the element is double-clicked. Any HTML element can receive this event.
2626
For example, consider the HTML:</p>
2727
<pre><code>&lt;div id="target"&gt;

entries/deferred.done.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dfd
5353
});
5454
5555
/* resolve the Deferred object when the button is clicked */
56-
$("button").bind("click", function() {
56+
$("button").on("click", function() {
5757
dfd.resolve("and");
5858
});
5959
]]></code>

entries/die.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
</argument>
2222
</signature>
2323
<longdesc>
24-
<p>Any handler that has been attached with <code>.live()</code> can be removed with <code>.die()</code>. This method is analogous to calling <code>.unbind()</code> with no arguments, which is used to remove all handlers attached with <code>.bind()</code>.
25-
See the discussions of <code>.live()</code> and <code>.unbind()</code> for further details.</p>
24+
<p>Any handler that has been attached with <code>.live()</code> can be removed with <code>.die()</code>. This method is analogous to calling <code>.off()</code> with no arguments, which is used to remove all handlers attached with <code>.on()</code>.
25+
See the discussions of <code>.live()</code> and <code>.off()</code> for further details.</p>
2626
<p>If used without an argument, .die() removes <em>all</em> event handlers previously attached using <code>.live()</code> from the elements.</p>
2727
<p><strong>As of jQuery 1.7</strong>, use of <code>.die()</code> (and its complementary method, <code>.live()</code>) is not recommended. Instead, use <a href="http://api.jquery.com/off/"><code>.off()</code></a> to remove event handlers bound with <a href="http://api.jquery.com/on/"><code>.on()</code></a></p>
2828
<p><strong>Note:</strong> In order for .die() to function correctly, the selector used with it must match exactly the selector initially used with .live().</p>

entries/error.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</argument>
1919
</signature>
2020
<longdesc>
21-
<p>This method is a shortcut for <code>.bind('error', handler)</code>.</p>
21+
<p>This method is a shortcut for <code>.on('error', handler)</code>.</p>
2222
<p>The <code>error</code> event is sent to elements, such as images, that are referenced by a document and loaded by the browser. It is called if the element was not loaded correctly.</p>
2323
<p>For example, consider a page with a simple image element:</p>
2424
<pre><code>&lt;img alt="Book" id="book" /&gt;</code></pre>

entries/event.namespace.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<example>
1212
<desc>Determine the event namespace used.</desc>
1313
<code><![CDATA[
14-
$("p").bind("test.something", function(event) {
14+
$("p").on("test.something", function(event) {
1515
alert( event.namespace );
1616
});
1717
$("button").click(function(event) {

entries/event.pageX.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<css>body {background-color: #eef; }
1212
div { padding: 20px; }</css>
1313
<html><![CDATA[<div id="log"></div>]]></html>
14-
<code><![CDATA[$(document).bind('mousemove',function(e){
14+
<code><![CDATA[$(document).on('mousemove',function(e){
1515
$("#log").text("e.pageX: " + e.pageX + ", e.pageY: " + e.pageY);
1616
}); ]]></code>
1717
</example>

0 commit comments

Comments
 (0)