From cb88857b52df6357edaf4e768e06075d3e597deb Mon Sep 17 00:00:00 2001 From: Aurelio De Rosa Date: Sat, 28 Feb 2015 22:41:25 +0000 Subject: [PATCH 1/2] Update on.xml Fixed issue #665 --- entries/on.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/entries/on.xml b/entries/on.xml index 0f2f9474..4fad283c 100644 --- a/entries/on.xml +++ b/entries/on.xml @@ -96,6 +96,21 @@ $( "button" ).on( "click", {

The focus and blur events are specified by the W3C to not bubble, but jQuery defines cross-browser focusin and focusout events that do bubble. When focus and blur are used to attach delegated event handlers, jQuery maps the names and delivers them as focusin and focusout respectively. For consistency and clarity, use the bubbling event type names.

In all browsers, the load, scroll, and error events (e.g., on an <img> element) do not bubble. In Internet Explorer 8 and lower, the paste and reset events do not bubble. Such events are not supported for use with delegation, but they can be used when the event handler is directly attached to the element generating the event.

The error event on the window object uses nonstandard arguments and return value conventions, so it is not supported by jQuery. Instead, assign a handler function directly to the window.onerror property.

+

The handler list for an element is set when the event is first delivered. This means that even if you try to remove an event handler inside another one for the same event executed first, the removed handler will be executed anyway. It will not be executed the following times because it's correctly removed. This behavior goes against the W3C events specification. It's worth noting that this is an edge case and this behavior allows to keep the logic simple. To better understand this case, consider the following code:

+
var $test = $( "#test" );
+
+function handler1() {
+  console.log( "handler1" );
+  $test.off( "click", handler2 );
+}
+
+function handler2() {
+  console.log( "handler2" );
+}
+
+$test.on( "click", handler1 );
+$test.on( "click", handler2 );
+

In the code above, handler2 will be executed anyway the first time even if it's removed using .off(). However, the handler will not be executed the following times the click event is triggered.

Display a paragraph's text in an alert when it is clicked: From 024db033802a9457cfb5c00aa939d374162f7f7b Mon Sep 17 00:00:00 2001 From: Aurelio De Rosa Date: Tue, 3 Mar 2015 14:34:55 +0000 Subject: [PATCH 2/2] Update on.xml PR updated based on the discussion --- entries/on.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entries/on.xml b/entries/on.xml index 4fad283c..9a7e66ed 100644 --- a/entries/on.xml +++ b/entries/on.xml @@ -96,7 +96,7 @@ $( "button" ).on( "click", {

The focus and blur events are specified by the W3C to not bubble, but jQuery defines cross-browser focusin and focusout events that do bubble. When focus and blur are used to attach delegated event handlers, jQuery maps the names and delivers them as focusin and focusout respectively. For consistency and clarity, use the bubbling event type names.

In all browsers, the load, scroll, and error events (e.g., on an <img> element) do not bubble. In Internet Explorer 8 and lower, the paste and reset events do not bubble. Such events are not supported for use with delegation, but they can be used when the event handler is directly attached to the element generating the event.

The error event on the window object uses nonstandard arguments and return value conventions, so it is not supported by jQuery. Instead, assign a handler function directly to the window.onerror property.

-

The handler list for an element is set when the event is first delivered. This means that even if you try to remove an event handler inside another one for the same event executed first, the removed handler will be executed anyway. It will not be executed the following times because it's correctly removed. This behavior goes against the W3C events specification. It's worth noting that this is an edge case and this behavior allows to keep the logic simple. To better understand this case, consider the following code:

+

The handler list for an element is set when the event is first delivered. Adding or removing event handlers on the current element won't take effect until the next time the event is handled. To prevent any further event handlers from executing on an element within an event handler, call event.stopImmediatePropagation(). This behavior goes against the W3C events specification. To better understand this case, consider the following code:

var $test = $( "#test" );
 
 function handler1() {