git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
jquery event: closes #5250. bind(), unbind() and one() support Object Literals (needs...
[jquery.git]
/
src
/
event.js
diff --git
a/src/event.js
b/src/event.js
index
c3c978b
..
76b1dfb
100644
(file)
--- a/
src/event.js
+++ b/
src/event.js
@@
-564,7
+564,16
@@
jQuery.each({
});
jQuery.fn.extend({
});
jQuery.fn.extend({
+ // TODO: make bind(), unbind() and one() DRY!
bind: function( type, data, fn, thisObject ) {
bind: function( type, data, fn, thisObject ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this.bind(key, data, type[key], fn);
+ }
+ return this;
+ }
+
if ( jQuery.isFunction( data ) ) {
thisObject = fn;
fn = data;
if ( jQuery.isFunction( data ) ) {
thisObject = fn;
fn = data;
@@
-577,6
+586,14
@@
jQuery.fn.extend({
},
one: function( type, data, fn, thisObject ) {
},
one: function( type, data, fn, thisObject ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this.one(key, data, type[key], fn);
+ }
+ return this;
+ }
+
if ( jQuery.isFunction( data ) ) {
thisObject = fn;
fn = data;
if ( jQuery.isFunction( data ) ) {
thisObject = fn;
fn = data;
@@
-593,6
+610,14
@@
jQuery.fn.extend({
},
unbind: function( type, fn ) {
},
unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+ return this;
+ }
+
return this.each(function() {
jQuery.event.remove( this, type, fn );
});
return this.each(function() {
jQuery.event.remove( this, type, fn );
});