Since we're using Event Delegation on the document object, I'm curiouswhy the selector even needs to be executed prior to calling the livemethod. Why not make it a jQuery function instead?$.live = function(selector, type, fn){ var r = $([]); r.selector = selector; if(type && fn) { r.live(type, fn); } return r;};There might be some confusion with this approach, since the jQueryobject being returned does not actually contain any nodes, but it'ssomething to think about.Thanks,Zach Leathermanhttp://www.zachleat.com/

Replies(4)

"I'm curious why the selector even needs to be executed prior tocalling the live method"...Probably so you can chain it.$('p').live('click', function() { console.log('clicked!')}).css({'color':'red'});

Sure, but you're sacrificing quite a bit in performance to getchaining.I think it would be helpful to have an alternative option, so thatdevs are aware of the tradeoff (I'm not asking to change $.fn.live),and my suggestion was to use $.live.

I'm not convinced you're sacrificing that much performance. One of thegreat things about .live() is that it can be called before the DOM iseven ready. The lack of nodes to search means that selection shouldreturn almost immediately.Jed Schmidt

@Zach - Chaining is very powerful, I like the existing functionalityas is. There are performance issues like you mention, but I haven'trun into a selector on a page that has caused me difficulty yet.*fingers crossed*. If I did, I would either just roll my own byputting the click event on the document and testing for a match to aselector or create a plugin doing what you suggest. Having both inthe core might just create confusion,$.live(selector, 'click', function () {}); vs. $(selector).live('click', function () {});And the latter is more 'jQuery-ish', at least in my mind.