Element.mooDispose = Element.dispose;
Element.dispose = function(element){
  /* your code */
  Element.mooDispose(element);
});

This kind of hackery may, actually, will *probably* cause you headaches at
some point.

On Fri, Feb 3, 2012 at 12:15 PM, Regis <[email protected]> wrote:

> So, I need some help. I need to run some code on an element and all of
> it's children when it's removed from the DOM via Mootools. destroy(),
> empty(), dispose(), etc. Since all of these end up calling dispose in the
> end, this is the method I would like to reimplement. I was trying to do
> something like:
>
> Element.implement('mooDispose', Element.prototype.dispose);
> Element.implement('dispose', function(){
>     /* my code */
>     this.mooDispose();
> });
>
> And this seems works fine when I call dispose on the element as
> $(el).dispose();  However, when I call $(el).destroy() which calls
> Element.dispose(this); it does not call my dispose, but rather the
> original dispose, thus going around my implementation. Is there a way I'm
> missing so Element.dispose calls my implementation of it? In the
> implementation method in Mootools, Element.dispose(this); should call my
> function with apply(el) from the, but something else must be happening I
> don't quite understand. I feel so close...
>
> Here's a jsfiddle. Notice that dispose calls mine, but destroy or empty
> does not: http://jsfiddle.net/rgthree/QG7Fa/
>
> Thanks!
>
>
>

Reply via email to