Hi, I was browsing through the new jQuery code and noticed that .live()
always binds events to document. I was wondering whether it would be
more efficient to bind them on the context if present - ie. to prevent
events from unnecessarily bubbling all the way up to document.

so that:

$('button', container).live('click', function(ev) {
    var button = this;
    ...
    ev.stopPropagation();
});

events are bound to 'container', and the function prevents further
propagation.

I know that this kind of thing can currently be done more efficiently
than using live like this:

$(container).bind('click', function(ev) {
    var button = $(ev.target).closest('button');
    ...
});

so wouldn't binding live on the context leverage live for more useful
situations like this, and take the strain off binding to document?

I've not had chance to test this out, I thought I'd raise the issue
for discussion first before spending too much time on the matter.
Maybe I've completely overlooked something ;)

Regards
- Mark Gibson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to