Reputation: 18094
If I wish to strip out some extra spaces, and ensure http:// is prepended to any input whenever a call like so is made
myModel.set('url','www.google.com');
Upvotes: 3
Views: 1165
Reputation: 671
Agree with @rjsvaljean, but if you really want to override set method for myModel then do it like that:
var MyModel = Backbone.Model.extend({
set: function(attributes, options) {
// 'strip out some extra spaces, and ensure http is prepended' here
return Backbone.Model.prototype.set.call(this, attributes, options);
}
});
Upvotes: 4