Hi, Yes, it will, removing an element (via Prototype or directly with Node.removeChild) removes that element and its children. Which is just as well, as the children would have no where to be otherwise.
Note that neither Prototype nor the underlying DOM methods will automatically remove event handlers from the removed elements, which can mean that memory remains in use even though the element isn't on the page anymore. You want to track what children you have event handlers on and remove the handlers as well. This is much easier if you're using event delegation to keep the number of handlers to a minimum. HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 2, 11:25 pm, Kostil <[email protected]> wrote: > Hi All, > > I am wondering if remove() method executed on top DIV (parent DIV > element) will automatically remove the children of this element (as in > remove them from the page and memory if appropriate)? Currently, I am > doing the following to remove the children: > > $('topdiv').childElements().each(function(e) { > RemoveChildren(e); > }); > > Where RemoveChildren(e) defined as: > > function RemoveChildren(e) > { > if (e.childElements().length > 0) > { > e.childElements().each(function(ee) { > RemoveChildren(ee); > }); > } > e.remove(); > > } > > The method above seems to work slow especially on IE where very > visible lag is apparent when executing this type of cleanup. > > Thank you in advance, --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
