javascript - MooTools: destroy() and events - Stack Overflow

When I .destroy() an Element object in MooTools, does .destroy() automatically internally call element.

When I .destroy() an Element object in MooTools, does .destroy() automatically internally call element.removeEvents(), or do I need to keep this in mind. (I'm removing elements from the DOM that have previously had element.addEvent() called.)

When I .destroy() an Element object in MooTools, does .destroy() automatically internally call element.removeEvents(), or do I need to keep this in mind. (I'm removing elements from the DOM that have previously had element.addEvent() called.)

Share Improve this question asked Jan 30, 2010 at 12:13 JamesBrownIsDeadJamesBrownIsDead 8211 gold badge7 silver badges7 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

.destroy() in MooTools, version 1.2.4:

destroy: function(){
    Element.empty(this);
    Element.dispose(this);
    clean(this, true);
    return null;
}

The clean(item, retain) function does .removeEvents() if the browser needs it:

var clean = function(item, retain){
    ....
    if (item.clearAttributes){
        var clone = retain && item.cloneNode(false);
        item.clearAttributes();
        if (clone) item.mergeAttributes(clone);
    } else if (item.removeEvents){          
    ....
};

You should be safe, it's emptying out the elements.

Also, credit for all code above to MooTools of course: http://mootools/

Yes, Mootools will call removeEvents() when you call destroy() on an element.

(The current implementation does this in a function called clean() that is called from destroy()).

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745188872a4615766.html

相关推荐

  • javascript - MooTools: destroy() and events - Stack Overflow

    When I .destroy() an Element object in MooTools, does .destroy() automatically internally call element.

    11小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信