On 16 Jun 2011, at 10:44, T.J. Crowder wrote:
On Jun 16, 9:11 am, Acu <[email protected]> wrote:
I am curious what happens with references to Events registered
through
Event.Observe when object bound with those evenst is removed with
Element.remove function. Are they automatically freed (like with
Event.unloadCache)? Or maybe one should unregister those events with
Event.stopObserving before removing object?
Prototype doesn't do anything to remove the handlers on `remove`,
they'll stay in memory.
If you know you've only set handlers on that element and none of its
children, yes, use `stopObserving`:
$("theElement").stopObserving().remove();
If there may be handlers on the element's children as well, use
`purge`[1]:
$("theElement").purge().remove();
It's not clear from the documentation, but `purge` does remove
handlers from the element's descendants.
[1] http://api.prototypejs.org/dom/Element/purge/
And of course, in quite a few cases event delegation might be a better
solution to start off with, either on the parent element or the window
object itself.
Best regards
Peter De Berdt
--
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.