次のような 3 つのバックボーン ビューがあります。
ParentView = Backbone.View.extend({
addUsers : function()
{
console.log("Parent's Add User");
},
addProject : function()
{
console.log("Parent's Add Project");
}
});
ChildView = ParentView.extend({
addProject : function()
{
var self = this;
console.log("Child's add Project");
self.constructor.__super__.addProject.apply(self);
}
});
GrandChildView = ChildView.extend({
addItem : function()
{
var self = this;
self.addProject();
},
addUsers : function()
{
var self = this;
console.log("Grand Child's Add users");
self.constructor.__super__.addUsers.apply(self);
}
});
var vChild = new ChildView();
vChild.addProject(); // works fine, by calling it own and parent's functions.
var vGrandChild = new GrandChildView();
vGrandChild.addUsers(); // This throws Maximum call stack size exceeded error,
GrandChildView の新しいインスタンスを作成し、その addUsers メソッドを呼び出すと、最大スタック サイズを超えてスローされます。これは、自分自身を呼び出し続けているためだと思います。しかし、把握することはできません。その理由はスーパーのメソッドを呼び出しているようです。
ありがとうございました。