How do I override / encapsulate the backbone 'set' method
backbone.js
Solution
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);
}
});
Problem
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'); ```