Asif Maniar

Software Engineer
posts - 16, comments - 10, trackbacks - 0

My Links

News

Article Categories

Archives

Post Categories

Image Galleries

IIS

Monday, October 05, 2009

jQuery Event Delegation

Recently I had to code some functionality that required event delegation in JavaScript.
After searching I came across this great post by Karl Swedberg about how events can be delegated using jQuery.
This can be a very useful approach if you want to add new elements to the DOM and have them react to events without re-binding events handlers or if your page simply has too many elements that need to be wired to an event.

The basic concept it simple: Instead of attaching an event to an individual element attach it to the parent and then get the target of the event when it is raised.

Read the complete post here:
http://www.learningjquery.com/2008/03/working-with-events-part-1

In his next article Karl looked at re-binding event handlers instead of delegation.
http://www.learningjquery.com/2008/05/working-with-events-part-2

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, October 05, 2009 2:59 PM | Feedback (0) | Filed Under [ jQuery ]

Powered by: