4 ms·
Sure (though I recommend just updating your code instead...) Only reason it's tricky is because there are two different forms of attributes that can be passed
by philfreo 14y ago
Sure (though I recommend just updating your code instead...)
Only reason it's tricky is because there are two different forms of attributes that can be passed to set. Something like this should work:
var oldSet = Backbone.Model.prototype.set;
Backbone.Model.prototype.set = function(key, val, options) {
if (key == null) return this;
if (typeof key === 'object') {
options = val;
}
options || (options = {});
options.validate = true;
oldSet.call(this, key, val, options);
};