it looks like .destroy() actually calls
browser.freeMem, which if you view the source code, runs the remove
events for you
Browser.freeMem = function(item){
if (!item) return;
if (Browser.Engine.trident && (/object/i).test(item.tagName)){
for (var p in item){
if (typeof item[p] == 'function') item[p] = $empty;
}
Element.dispose(item);
}
if (item.uid && item.removeEvents) item.removeEvents();
};
On Oct 3, 9:19 am, Vortexmind <[EMAIL PROTECTED]> wrote:
> Hi all
> Here is what the doc are saying about this function
>
> "Empties an Element of all its children, removes and garbages the
> Element. Useful to clear memory before the pageUnload."
>
> But ... this is not clear (at least for me ^_^ )
>
> Suppose I have this DOM subtree ...
>
> <div id="father">
> <div id="resize_handle">
> <div id="custom_handle">
> </div>
>
> Suppose 'father' is Drag resizable, by his 'resize_handle' handle.
> Suppose also I've attached a custom event on 'custom_handle' , for
> example on "click" event to "foo" function
>
> What is the best way of destroy this composite element? Does destroy
> also takes care of events or do I have to manually do it?
>
> I did this way
>
> var ref = $('father').makeResizable ...
>
> ....
> ref.detach();
> $('custom_handle).removeEvent('click',foo);
> $('father').destroy();
>
> Or I could simply do $('father').destroy() without fear of memory
> leaks?
>
> Thank you
>
> // destroy panel with children recursively
> $(id).destroy();