Added $().data(), $().removeData(), and .bind("click!"). .data() and .removeData() handle namespaced data, .data() triggers a "set-KEY" event on all modified elements, and .bind("click!") only triggers a click (and no namespaced events).

This commit is contained in:
John Resig 2008-02-03 04:05:24 +00:00
parent 25c76232c6
commit 77da94552e
3 changed files with 79 additions and 1 deletions

View file

@ -477,6 +477,26 @@ jQuery.fn = jQuery.prototype = {
andSelf: function() {
return this.add( this.prevObject );
},
data: function( key, value ){
if ( value == null ) {
if ( this.length ) {
var data = jQuery.data( this[0], key );
return data == null ?
jQuery.data( this[0], key.split(".")[0] ) :
data;
}
} else
return this.trigger("set-" + key + "!", [value]).each(function(){
jQuery.data( this, key, value );
});
},
removeData: function( key ){
return this.each(function(){
jQuery.removeData( this, key );
});
},
domManip: function( args, table, reverse, callback ) {
var clone = this.length > 1, elems;