I have a case that uses view inheritance, and my code looks essentially like:
parentView = Backbone.View.extend({
events: {
\"some event\": \"busines
Actually, I'dont know if this solves your case, but I usually do this: My solution is completely wrong. Here's why:this.constructor.__super__.initialize.apply(this, arguments);
and works like a charm.
var Model1 = Backbone.Model.extend({
method: function () {
// does somehting cool with `this`
}
});
var Model2 = Model1.extend({
method: function () {
this.constructor.__super__.method.call(this);
}
});
var Model3 = Model2.extend({
method: function () {
this.constructor.__super__.method.call(this);
}
});
var tester = new Model3();
// Boom! Say hallo to my little stack-overflowing recursive __super__ call!
tester.method();
The call to this.constructor.__super__
in Model2::method
will resolve to (drum-roll) Model2::method
.
Always use ExplicitClassName.__super__.methodName.call(this, arg1, arg2 /*...*/)
or Coffee-script's super
.