W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2009

[whatwg] <a onlyreplace>

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Sun, 18 Oct 2009 14:43:21 -0500
Message-ID: <dd0fbad0910181243w3dc3d6e5y49a478d1e5eecb3f@mail.gmail.com>
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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:18 UTC