You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: page/events/event-extensions.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -112,23 +112,23 @@ When these properties are defined, the following behavior occurs in the jQuery e
112
112
So given the special event above, this code shows that a pushy isn't removed by removing clicks. That might be an effective way to defend against an ill-behaved plugin that didn't namespace its removal of click events, for example:
113
113
114
114
```
115
-
var $p = $( "p" );
115
+
var elem = $( "p" );
116
116
117
-
$p.on( "click", function( e ) {
118
-
$( "body" ).append( "I am a " + e.type + "!" );
117
+
elem.on( "click", function( event ) {
118
+
$( "body" ).append( "I am a " + event.type + "!" );
119
119
});
120
120
121
-
$p.on( "pushy", function( e ) {
122
-
$( "body" ).append( "I am pushy but still a " + e.type + "!" );
121
+
elem.on( "pushy", function( event ) {
122
+
$( "body" ).append( "I am pushy but still a " + event.type + "!" );
123
123
});
124
124
125
-
$p.trigger( "click" ); // triggers both handlers
125
+
elem.trigger( "click" ); // triggers both handlers
126
126
127
-
$p.off( "click" );
127
+
elem.off( "click" );
128
128
129
-
$p.trigger( "click" ); // still triggers "pushy"
129
+
elem.trigger( "click" ); // still triggers "pushy"
130
130
131
-
$p.off( "pushy" );
131
+
elem.off( "pushy" );
132
132
```
133
133
134
134
These two properties are often used in conjunction with a `handle` hook function; the hook might, for example, change the event name from "click" to "pushy" before calling event handlers. See below for an example.
0 commit comments