Reputation: 5929
I have a setup of multi level backbone inheritance, but would like to call back of the previous super class. Not sure if is possible.
Scenario:
BasicView -> MediumView -> HardView
Where I would love that when HardView created, it will loops to call previous super class initialize function.
Example is here:
http://jsfiddle.net/mochatony/bwB9W/
Upvotes: 3
Views: 384
Reputation: 28278
There are no implicit references to the superclass in standard JavaScript - you have to explicitly call the supertype's methods
var Basic = Backbone.View.extend({
initialize: function(){
console.log('base');
}
});
var Medium = Basic.extend({
initialize: function() {
console.log(Basic.prototype.initialize.apply(this, arguments));
console.log('medium');
}
});
var Hard = Medium.extend({
initialize:function(){
console.log(Medium.prototype.initialize.apply(this, arguments));
console.log('hard');
}
});
var hard = new Hard();
Upvotes: 4