[whatwg] <a onlyreplace>

On Sun, Oct 18, 2009 at 2:31 PM, Nelson Menezes
<flying.mushroom at gmail.com> wrote:
> Sorry, I had in mind being able to re-apply event listeners to the DOM
> once the new content was loaded. Of course you can do that in several
> localised places rather than overall on the whole document (it will be
> more efficient anyway).

Well, the best way to do this is probably to use event delegation in
the first place, so you don't have to reinitialize listeners every
time.  jQuery makes this extremely easy with the $(target).live(event,
callback) functionality, but it's pretty simple to do by hand as well.

> Still, it would be nice to be able to identify
> that "all my bits of content are now loaded" and being able to have an
> event handler that gets called once, rather than having to account for
> all the IDs loading independently: I might want to do something that
> involves several parts of the new content (e.g. highlight it to make
> the change obvious to the user).

Worst case, you just have a listener on <body> which notes the id of
the target as each swapIn event bubbles up to it, and calls some
function when it's received all of them.  This would be really easy to
automate.

~TJ

Received on Sunday, 18 October 2009 12:43:21 UTC