views:

70

answers:

1

There's a div element on my page. When the page loads, I want to specify somehow that after destroy() is called on this element (based on what the user does in the UI), that a function I specify fires. How can I attach to the destroy() event?

A: 

you can just build a new element method - something like this.

Element.implement({
    smartDestroy: function(callback, options) {
        this.destroy();
        var options = options || {};
        if ($type(callback) === "function")
            callback.pass(options)();

        return null;
    }
});

$("foo").smartDestroy(function(options) {
    alert(options.message);
}, {message: "gone"});

aside from that, destroy() has no events it can raise - you should be ok with above and you can tweak it to do whatever you need.

http://mootools.net/shell/23D8p/

Dimitar Christoff
p.s. you've asked 5 questions and not accepted a single answer, if you don't see your questions through, it's not helping anyone else that might be having the same problems...
Dimitar Christoff