The problem is, when you are updating the div, new elements don't have their onclick wired to your function. The function to attach the click event handler has already run.

Event delegation solves this by delegating the click events to the parent element.

If you have more questions, feel free to ask.

--Daniel

Sent from my iPhone

On Nov 27, 2009, at 10:25 AM, Jake <[email protected]> wrote:

The first link I have seen.

I'm still lost as to how it applies to my problem (though I assure
you, I assume you are correct).

When the page with the listener, and the existing value of the dynamic
<div> containing the <a> links first load, all is well, clicks are
detected and acted on.

When the <div> is updated with additional / fewer / different <a>
links, none are detected.

But I'm unsure how this relates to Event Delegation.

Is there something wrong with my code (as transcribed in my first
message above)?

- Jake

Reply via email to