Refactoring method that was previously injected with implement

Posted by ryber on Stack Overflow See other posts from Stack Overflow or by ryber
Published on 2010-07-08T16:33:54Z Indexed on 2010/12/22 11:54 UTC
Read the original article Hit count: 196

Filed under:
|

Greetings, I'm trying to override or extend the Element.show() and .hide() methods in mootools in order to add some WAI-Aria toggling. I was trying to use the Class.Refactor() method like this:

 Element = Class.refactor(Element, {

 show: function(displayString) {
   result = this.previous(displayString);
   // Do my thing
   return result;
 },

 hide: function() {
   result = this.previous();
   // Do my thing
   return result;
 }

});

however, this is not working, previous is null and I think the reason is that Mootools injects those methods through Element.implement. So the methods are not native?

I have figured out how to completely replace .show and .hide but I would like to retain all of their existing functionality and just add to it. Any ideas?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about mootools