I don’t see any difference between the two functions.
Using the following JavaScript code:
var x = {};
$(x).bind({
setData: function (event, key, value) {
console.log("setData()", key, value);
},
changeData: function (event, key, value) {
console.log("changeData()", key, value);
}
});
$(x).data("key1", "alpha");
$(x).data("key1", "beta");
$(x).data("key2", "gamma");
… I get the following in the console:
setData() key1 alpha
changeData() key1 alpha
setData() key1 beta
changeData() key1 beta
setData() key2 alpha
changeData() key2 alpha
Both events fire every time.
The only place either is called in all the code is in the data function, one is called before the set and the other right after, but the values passed in are the same.