Tweaked the .data() event triggering - it now triggers a single 'setData' event,...
[jquery.git] / src / core.js
index 098d4bd..6997f89 100644 (file)
@@ -477,6 +477,28 @@ jQuery.fn = jQuery.prototype = {
        andSelf: function() {
                return this.add( this.prevObject );
        },
+
+       data: function( key, value ){
+               var parts = key.split(".");
+
+               if ( value == null ) {
+                       if ( this.length ) {
+                               var data = jQuery.data( this[0], key );
+                               return data == null ?
+                                       jQuery.data( this[0], parts[0] ) :
+                                       data;
+                       }
+               } else
+                       return this.trigger("setData" + (parts[1] ? "." + parts[1] : "") + "!", [parts[0], 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;