aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2010-02-27 09:02:13 -0500
committerjeresig <jeresig@gmail.com>2010-02-27 09:02:13 -0500
commita45372a4c5cfd33c4ff12b145bd79fec2fe0d382 (patch)
treed742e359770aa2f7070626e4e71374518b85b501 /src/event.js
parentba7195e3f90b3a3130ac0b15880ba2f27106f568 (diff)
downloadjquery-a45372a4c5cfd33c4ff12b145bd79fec2fe0d382.tar.gz
jquery-a45372a4c5cfd33c4ff12b145bd79fec2fe0d382.zip
Adding in .bind(name, false), .unbind(name, false) support - an easy way to just stop bubbling and the default action on an element. Fixes #6188.
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/event.js b/src/event.js
index 779c069dc..a7900c98e 100644
--- a/src/event.js
+++ b/src/event.js
@@ -25,6 +25,10 @@ jQuery.event = {
elem = window;
}
+ if ( handler === false ) {
+ handler = returnFalse;
+ }
+
var handleObjIn, handleObj;
if ( handler.handler ) {
@@ -138,6 +142,10 @@ jQuery.event = {
return;
}
+ if ( handler === false ) {
+ handler = returnFalse;
+ }
+
var ret, type, fn, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
elemData = jQuery.data( elem ),
events = elemData && elemData.events;
@@ -830,7 +838,7 @@ jQuery.each(["bind", "one"], function( i, name ) {
return this;
}
- if ( jQuery.isFunction( data ) ) {
+ if ( jQuery.isFunction( data ) || data === false ) {
fn = data;
data = undefined;
}
@@ -1072,8 +1080,13 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
// Handle event binding
jQuery.fn[ name ] = function( data, fn ) {
- return data || fn ?
- this.bind( name, fn ? data : null, fn || data ) :
+ if ( fn == undefined ) {
+ fn = data;
+ data = null;
+ }
+
+ return arguments.length > 0 ?
+ this.bind( name, data, fn ) :
this.trigger( name );
};