Tweaked the .data() event triggering - it now triggers a single 'setData' event, passing in a key value pair of what was changed.
This commit is contained in:
parent
703e89ba30
commit
4a11e6d70b
2 changed files with 16 additions and 14 deletions
|
@ -479,15 +479,17 @@ jQuery.fn = jQuery.prototype = {
|
|||
},
|
||||
|
||||
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], key.split(".")[0] ) :
|
||||
jQuery.data( this[0], parts[0] ) :
|
||||
data;
|
||||
}
|
||||
} else
|
||||
return this.trigger("set-" + key + "!", [value]).each(function(){
|
||||
return this.trigger("setData" + (parts[1] ? "." + parts[1] : "") + "!", [parts[0], value]).each(function(){
|
||||
jQuery.data( this, key, value );
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue