Skip to content

Instantly share code, notes, and snippets.

@karlwestin
Created February 7, 2012 00:31
Show Gist options
  • Save karlwestin/1756183 to your computer and use it in GitHub Desktop.
Save karlwestin/1756183 to your computer and use it in GitHub Desktop.
Overriding set-method in Backbone.js models
set: function(attrs, options) {
_.each(attrs, function(val, key) {
if(!!this.validations[key])
attrs[key] = this.filters[ this.validations[key].filter ](val);
}, this);
Backbone.Model.prototype.set.call(this, attrs, options);
return this;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment