Connect with me
Search
Twitter Feed
Navigation
« Dynamic Data - Formatting Values | Main | Dynamic Data - Working with ASP.NET Membership provider and hiding the aspnet tables using T4 Templates »
Thursday
Jan222009

jQuery 1.3 released!

jQuery 1.3 was released and the most useful new feature is the live event!

Previously in older versions when you dynamically added new DOM elements into you page your event handlers would not automatically be attached to those elements.

You run into this issue a lot if you use AJAX or are creating lots of elements on the fly. The only trick before this new feature was to rebind all those events whenever a new element was added.

With the live event, it automatically binds up all current and future elements matching the selector

So instead of using:

// Will only add the event handler to current matched elements in the DOM
$("div").click(function() { doSomething(); });

You can use

// Will add the event handler to all current and future matched elements in the DOM
$("div").live("click", function() { doSomething(); });

Check it out, it’s a great new feature.

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>