开发者

MooTools: Attaching to destroy() event

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?


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜