How to get this.grandparent() functionality in Mootools?

Posted by RyOnLife on Stack Overflow See other posts from Stack Overflow or by RyOnLife
Published on 2010-06-04T16:25:29Z Indexed on 2010/06/07 14:22 UTC
Read the original article Hit count: 277

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about mootools