[thelist] javascript : events not firing after dom alteration

Shaun shaun at porkandpaws.com
Sat Jul 21 04:14:41 CDT 2007


Thanks
Couple of questions

	detach events how?

I currently don't use any librarys although of course i could
If i was just to create an event attachment method any pointers on good
examples to look at?

Thanks

Shaun

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org]On Behalf Of Volkan Ozcelik
Sent: 21 July 2007 10:07
To: thelist at lists.evolt.org
Subject: Re: [thelist] javascript : events not firing after dom
alteration


Hi Shaun,

On 7/21/07, shaun at porkandpaws.com <shaun at porkandpaws.com> wrote:
>
>
> Part of the action replaces this link.


When you replace the link, you introduce a brand new  element to the  DOM
structure.
The old link and hence its old event attachments are not available any more.

Ideally;

1. You should detach all event handlers *before* altering the element (due
to memory leakage and closure issues -- good boys clean up their mess.)
2. Insert new element to DOM via appendChild or something similar (or for
the lazy men out there; setting the innerHTML of the container parent)
3. re-attach the event handler with your favorite event attachment method of
your favorite library.

HTH,
--
Volkan Ozcelik
+> linkibol.com - in seek of quality links: http://www.linkibol.com/
+> Going solo in Turkish: http://www.fikribol.com/donkisot/
+> My projects/studies/trials/errors : http://www.sarmal.com/
+> Sardalya JavaScript Library: http://www.sarmal.com/sardalya/
--

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !





More information about the thelist mailing list