On Dec 3, 3:35 pm, Rob Cluett <rob.clu...@gmail.com> wrote:
> RE: Element.remove(DOMelement)
> Does this method remove all children of the specified DOMelement
> before removing the specified DOMelement or must I delete all of the
> DOMelements children, grandchildran, etc. first?
Removing an element, by its nature, removes all of its descendants.
Neither you nor Prototype needs to do anything special to make that
> RE: Element.stopObserving(DOMelement)
> Does this method remove all events being observed for the given
> DOMelement or must I stop each one individually? At what point does
> this actually get removed from the DOM (garbage collection)?
Per the docs, if you call stopObserving without specifying either
an event name or a handler, all events hooked up to that element (via
Prototype) will be removed. They are removed from the element
immediately. When any memory consumed by those event handlers is
actually released is dependant on the browser's implementation and
varies dramatically across browsers.
> RE: Function.bindAsEventListener
> Should Element.StopObserving work to immediatly remove everything
> added to the DOM when using BindAsEventListener?
You almost certainly don't need to use bindAsEventListener; more here
. Whether you use it or not, stopObserving removes the event
handler from the element immediately.
> I'm seeing a slew of memory leaks in my application and can only
> assume elements are not being removed from the DOM as they should be.
> Any help would be appreciated. I'm going though the prototype.js code
> now by any insight would be great. Thanks guys.
Be sure to disconnect events prior to removing elements, that could be
part of the problem. For example, if you have:
And you have:
Suppose you do this:
You've just left two event handlers dangling around in memory.
Alternately, suppose you did this:
You've still left one event handler dangling around in memory, the one
on the 'inner' div. You'd need to do this to clean up completely:
Your application logic needs to be sure it knows about handlers it
needs to remove. Although you could do this:
outer = $('outer');
...doing so is very inefficient.
Independent Software Consultant
tj / crowder software / com
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 prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group at