Backbone.js super() function
Backbone.Model.prototype._super = function(funcName){
return this.constructor.__super__[funcName].apply(this, _.rest(arguments));
}
// used like this
Model = Backbone.model.extend({
set: function(arg){
// your code here
// call the super class function
this._super('set', arg);
}
});
// It is kind of a bummer that you still have to specify the functions name,
// but I like it better than the alternatives.
// using the constructor with out the super wrapper:
this.constructor.__super__.set.apply(this, args)
// or referencing the object directly:
Backbone.Model.prototype.set.apply(this, args);
This adds a super function to the Backbone.Model prototype that allows you to call the a function on the super class of a model.
Comments are only visible to Forrst members. Log in or Request an invite.
