[Proto-Scripty] Re: Will remove() method on top DIV element automatically remove children of that element?

2009-08-03 Thread Alex McAuley

onclick will go as its a DOM0 style handler.

Anything in the observe (attached as delegation) will not and you will have 
to remove manauly with stopObserving();

Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: "Kostil" 
To: "Prototype & script.aculo.us" 
Sent: Monday, August 03, 2009 3:09 PM
Subject: [Proto-Scripty] Re: Will remove() method on top DIV element 
automatically remove children of that element?



First of all, thank you for a very detailed answer. From that arises
one more question: when you say event handlers are not remove do you
mean the event handlers that where added dynamically with commands
such as Element.observed and window.addEventListener won't be removed,
do you also talk about methods that are creates as part of HTML syntax
such as ? as most of
the dynamic content I create is using he Template class of prototype
where actions on those objects are taken from links populated as I've
described above (using an HTML within the Template). Will these event
invocations also provide a problem and need to be tracked?

Thank you,


On Aug 2, 10:29 pm, "T.J. Crowder"  wrote:
> 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  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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Will remove() method on top DIV element automatically remove children of that element?

2009-08-03 Thread Kostil

First of all, thank you for a very detailed answer. From that arises
one more question: when you say event handlers are not remove do you
mean the event handlers that where added dynamically with commands
such as Element.observed and window.addEventListener won't be removed,
do you also talk about methods that are creates as part of HTML syntax
such as ? as most of
the dynamic content I create is using he Template class of prototype
where actions on those objects are taken from links populated as I've
described above (using an HTML within the Template). Will these event
invocations also provide a problem and need to be tracked?

Thank you,


On Aug 2, 10:29 pm, "T.J. Crowder"  wrote:
> 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  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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Will remove() method on top DIV element automatically remove children of that element?

2009-08-02 Thread T.J. Crowder

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  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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---