I have built a class in Mootools and extended it twice, such that there is a grandparent, parent, and child relationship:
var SomeClass1 = new Class({
initialize: function() {
// Code
},
doSomething: function() {
// Code
}
});
var SomeClass2 = new Class({
Extends: SomeClass1,
initialize: function() {
this.parent();
},
doSomething: function() {
this.parent();
// Some code I don't want to run from Class3
}
});
var SomeClass3 = new Class({
Extends: SomeClass2,
initialize: function() {
this.parent();
},
doSomething: function() {
this.grandParent();
}
});
From Class3
, the child, I need call the doSomething()
method from Class1
, the grandparent, without executing any code in Class2#doSomething()
, the parent.
What I need is a grandParent()
method to complement the Mootools parent()
, but it appears that one does not exist.
What's the best way to accomplish this in either Mootools or pure JavaScript? Thanks.
UPDATE:
I should have mentioned: I realized that poor design has left me asking this question in the first place. A mixin would be ideal, but I inherited the code and don't have time for a refactor at the moment.