jQuery 1.3

Two days ago jQuery 1.3 was released, and today I finally had some time to take a look at the features and enhancements. A big fat kudos goes out to everyone involved. I am a huge fan of jQuery, and that love just seems to grow with time.

Just a few weeks ago I was looking for a way of accessing the selector from within the method, and now you can do it. Nice!

That being said, there is one feature addition that doesn’t do it for me: .live();

If you haven’t read the documentation yet, you can do so here. The long and short of it is that they’ve made it so that bound events live on in a page after the page has finished loading and new page elements have been added. In other words, after a page has loaded, you can load new page contents (say, with ajax), and elements within the newly added xhtml will have event bindings applied even though the javascript on the page has been parsed already.

This is a very useful idea that was accomplished in the past with a jquery plugin: livequery. The shortcoming of the new core live event binding is that (as far as I can tell) there is no way to simply apply the live method to page load.

For example, if I have a bit of jquery code that highlights all “strong” tags in a page and colors them red:

$('strong').css('color', 'red');

Now, with livequery, I can make sure that this bit of code gets applied to xhtml loaded via ajax after page load by doing this:

$('strong').livequery(function() {
    $(this).css('color', 'red');

However, the core .live() method doesn’t have this ability. Why? Is that really difficult to accomplish in the core?

Have I overlooked something? Am I wrong? I hope I’m wrong, because it seems silly to have to include the livequery plugin on every page load just for this one feature.