Bug Tracker

Modify

Ticket #5595 (closed bug: worksforme)

Opened 3 years ago

Last modified 3 years ago

Live Event Binds Ignore Context

Reported by: chrismjohnson Owned by: brandon
Priority: minor Milestone: 1.4
Component: event Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

Using the live event bind (.live) on a jQuery collection resulting from a .find, the event is bound to the selector of the .find with no regard for the parent collection of the .find.

The livequery plugin appears to respect the context properly.

Examples attached.

Attachments

live_event_bug.zip Download (25.0 KB) - added by chrismjohnson 3 years ago.

Change History

Changed 3 years ago by chrismjohnson

comment:1 Changed 3 years ago by mcm

If you read the documentation  http://docs.jquery.com/Events/live it says Live events currently only work when used against a selector as in $('.dropdown li').live(...) and not $(elem).find("li").live(...).

To fix you will find that in your function outside of the each loop this refers to $('.dropdown') and not an element so you can call your this.find('li').live('click', ...) method there and it should work since it's equivalent to $(this.selector + ' li').live(...).

I'm surprised livequery works but if you try a more obvious example like:
$($(".dropdown")[0]).find("body li").livequery("click", function() { alert(this); });
Then it fails in livequery just like it does in jQuery in your example.

comment:2 Changed 3 years ago by john

  • Status changed from new to closed
  • Resolution set to worksforme

This has already been resolved in jQuery 1.4.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.