whatever DOM elements you replace you will also loose their respective
events. it doesn't matter whether they are replaced by elements
matching their tag, id and class.

either you re-apply the needed events to the new elements or you use
event delegation on a static parent element (an element that you are
sure won't get replaced). if you're not familiar with event delegation
just google it.

On Dec 12, 5:42 pm, rpflo <rpflore...@gmail.com> wrote:
> So I've got a div named joe in a div named boxingRing.
>
> Joe's got a button called dudesFace with a 'click' event (that fires
> the function punchDude, but that's irrelevant).
>
> If I use Request.HTML and update boxingRing with my new content,
> containing a div named craig,
> with a new button called dudesFace
> and I add a new click event on dudesFace (to punchDude)
>
> did the old click event on the old dudesFace die when boxingRing was
> updated or if I now click dudesFace will I actually punchDude twice
> because I've got two events on it?
>
> Basic question is, if a div had elements with events and it gets
> updated via Request.HTML, do those events die or will I just keep
> filling up the browser's brain with a million events every time I
> update the div?

Reply via email to