From 2d3641f5c5c770c7c7f4db12ffc3c6a6fbf2899b Mon Sep 17 00:00:00 2001 From: Aurelio De Rosa Date: Sun, 10 Jul 2016 12:26:58 +0100 Subject: [PATCH 1/3] delegate: Document the method was deprecated in jQuery 3 Fixes gh-945 --- categories.xml | 5 +++++ entries/delegate.xml | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/categories.xml b/categories.xml index 55038248..f2ee15fa 100644 --- a/categories.xml +++ b/categories.xml @@ -66,6 +66,11 @@

For more information, see the Release Notes/Changelog at https://blog.jquery.com/2013/05/24/jquery-1-10-0-and-2-0-1-released/

]]> + + + diff --git a/entries/delegate.xml b/entries/delegate.xml index e1670e84..aa7056dd 100644 --- a/entries/delegate.xml +++ b/entries/delegate.xml @@ -1,5 +1,5 @@ - + .delegate() Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements. @@ -41,7 +41,7 @@ -

As of jQuery 1.7, .delegate() has been superseded by the .on() method. For earlier versions, however, it remains the most effective means to use event delegation. More information on event binding and delegation is in the .on() method. In general, these are the equivalent templates for the two methods:

+

As of jQuery 3.0, .delegate() has been deprecated. It was superseded by the .on() method since jQuery 1.7, so its use was already discouraged. For earlier versions, however, it remains the most effective means to use event delegation. More information on event binding and delegation is in the .on() method. In general, these are the equivalent templates for the two methods:


 // jQuery 1.4.3+
 $( elements ).delegate( selector, events, data, handler );
@@ -148,4 +148,5 @@ $( "button" ).click(function() {
   
   
   
+  
 

From bf744c484d241b0bcda1162e817d960ced54001a Mon Sep 17 00:00:00 2001
From: Aurelio De Rosa 
Date: Sun, 10 Jul 2016 12:40:10 +0100
Subject: [PATCH 2/3] Added bind, unbind, and undelegate

---
 entries/bind.xml       | 5 +++--
 entries/delegate.xml   | 2 +-
 entries/unbind.xml     | 6 ++++--
 entries/undelegate.xml | 5 +++--
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/entries/bind.xml b/entries/bind.xml
index a81e46a8..05856faa 100644
--- a/entries/bind.xml
+++ b/entries/bind.xml
@@ -1,5 +1,5 @@
 
-
+
   .bind()
   
     1.0
@@ -34,7 +34,7 @@
   
   Attach a handler to an event for the elements.
   
-    

As of jQuery 1.7, the .on() method is the preferred method for attaching event handlers to a document. For earlier versions, the .bind() method is used for attaching an event handler directly to elements. Handlers are attached to the currently selected elements in the jQuery object, so those elements must exist at the point the call to .bind() occurs. For more flexible event binding, see the discussion of event delegation in .on() or .delegate().

+

As of jQuery 3.0, .bind() has been deprecated. It was superseded by the .on() method for attaching event handlers to a document since jQuery 1.7, so its use was already discouraged. For earlier versions, the .bind() method is used for attaching an event handler directly to elements. Handlers are attached to the currently selected elements in the jQuery object, so those elements must exist at the point the call to .bind() occurs. For more flexible event binding, see the discussion of event delegation in .on() or .delegate().

Any string is legal for eventType; if the string is not the name of a native DOM event, then the handler is bound to a custom event. These events are never called by the browser, but may be triggered manually from other JavaScript code using .trigger() or .triggerHandler().

If the eventType string contains a period (.) character, then the event is namespaced. The period character separates the event from its namespace. For example, in the call .bind( "click.name", handler ), the string click is the event type, and the string name is the namespace. Namespacing allows us to unbind or trigger some events of a type without affecting others. See the discussion of .unbind() for more information.

There are shorthand methods for some standard browser events such as .click() that can be used to attach or trigger event handlers. For a complete list of shorthand methods, see the events category.

@@ -259,4 +259,5 @@ $( "div.test" ).bind({ +
diff --git a/entries/delegate.xml b/entries/delegate.xml index aa7056dd..10641ae6 100644 --- a/entries/delegate.xml +++ b/entries/delegate.xml @@ -41,7 +41,7 @@ -

As of jQuery 3.0, .delegate() has been deprecated. It was superseded by the .on() method since jQuery 1.7, so its use was already discouraged. For earlier versions, however, it remains the most effective means to use event delegation. More information on event binding and delegation is in the .on() method. In general, these are the equivalent templates for the two methods:

+

As of jQuery 3.0, .delegate() has been deprecated. It was superseded by the .on() method since jQuery 1.7, so its use was already discouraged. For earlier versions, however, it remains the most effective means to use event delegation. More information on event binding and delegation is in the .on() method. In general, these are the equivalent templates for the two methods:


 // jQuery 1.4.3+
 $( elements ).delegate( selector, events, data, handler );
diff --git a/entries/unbind.xml b/entries/unbind.xml
index e6be9a13..11d55d3f 100644
--- a/entries/unbind.xml
+++ b/entries/unbind.xml
@@ -1,5 +1,5 @@
 
-
+
   .unbind()
   Remove a previously-attached event handler from the elements.
   
@@ -31,7 +31,8 @@
     1.0
   
   
-    

Event handlers attached with .bind() can be removed with .unbind(). (As of jQuery 1.7, the .on() and .off() methods are preferred to attach and remove event handlers on elements.) In the simplest case, with no arguments, .unbind() removes all handlers attached to the elements:

+

Event handlers attached with .bind() can be removed with .unbind(). As of jQuery 3.0, .unbind() has been deprecated. It was superseded by the .off() method since jQuery 1.7, so its use was already discouraged.

+

In the simplest case, with no arguments, .unbind() removes all handlers attached to the elements:


 $( "#foo" ).unbind();
     
@@ -155,4 +156,5 @@ $( "p" ).unbind( "click", foo ); // ... foo will no longer be called. +
diff --git a/entries/undelegate.xml b/entries/undelegate.xml index 842a504a..6f8c7df3 100644 --- a/entries/undelegate.xml +++ b/entries/undelegate.xml @@ -1,5 +1,5 @@ - + .undelegate() Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. @@ -43,7 +43,7 @@ -

The .undelegate() method is a way of removing event handlers that have been bound using .delegate(). As of jQuery 1.7, the .on() and .off() methods are preferred for attaching and removing event handlers.

+

The .undelegate() method is a way of removing event handlers that have been bound using .delegate(). As of jQuery 3.0, .undelegate() has been deprecated. It was superseded by the .off() method since jQuery 1.7, so its use was already discouraged.

Can bind and unbind events to the colored button. @@ -124,4 +124,5 @@ $( "form" ).undelegate( ".whatever" ); +
From d348113e5a1993aa53e324258436d27dfe847e80 Mon Sep 17 00:00:00 2001 From: Aurelio De Rosa Date: Sun, 17 Jul 2016 15:54:13 +0100 Subject: [PATCH 3/3] Updates based on feedback --- entries/unbind.xml | 4 ++-- entries/undelegate.xml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/entries/unbind.xml b/entries/unbind.xml index 11d55d3f..c53dd6af 100644 --- a/entries/unbind.xml +++ b/entries/unbind.xml @@ -31,8 +31,8 @@ 1.0 -

Event handlers attached with .bind() can be removed with .unbind(). As of jQuery 3.0, .unbind() has been deprecated. It was superseded by the .off() method since jQuery 1.7, so its use was already discouraged.

-

In the simplest case, with no arguments, .unbind() removes all handlers attached to the elements:

+

As of jQuery 3.0, .unbind() has been deprecated. It was superseded by the .off() method since jQuery 1.7, so its use was already discouraged.

+

Event handlers attached with .bind() can be removed with .unbind(). In the simplest case, with no arguments, .unbind() removes all handlers attached to the elements:


 $( "#foo" ).unbind();
     
diff --git a/entries/undelegate.xml b/entries/undelegate.xml index 6f8c7df3..f97e6b01 100644 --- a/entries/undelegate.xml +++ b/entries/undelegate.xml @@ -43,7 +43,8 @@ -

The .undelegate() method is a way of removing event handlers that have been bound using .delegate(). As of jQuery 3.0, .undelegate() has been deprecated. It was superseded by the .off() method since jQuery 1.7, so its use was already discouraged.

+

As of jQuery 3.0, .undelegate() has been deprecated. It was superseded by the .off() method since jQuery 1.7, so its use was already discouraged.

+

The .undelegate() method is a way of removing event handlers that have been bound using .delegate().

Can bind and unbind events to the colored button.