The .live() method uses event delegation under the hood. doing this:

$('a').live('click', function() {
  // do something
});

is like doing this:

$(document).bind('click', function(event) {
  if ($(event.target).closest('a').length) {
    // do something
  }
});

except that with .live() the selector engine does have to initially traverse the DOM to find all of the <a> elements just by virtue of 'a' being in the jQuery function. not sure, but that might be changing in 1.4. Also, I haven't had a chance to look yet, but 1.4 also might let you pass in a context for .live() so you don't have to bind to document each time.

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Dec 4, 2009, at 3:39 PM, MorningZ wrote:

Nah. Using .live() wires up one event handler to document.

--Karl

Doh, shame on me for my lack of facts on that ".live()"... i'll read
up on it some, as i usually, well always, take the delegation
route......

Reply via email to