Bug Tracker

Modify

Ticket #4089 (closed bug: invalid)

Opened 4 years ago

Last modified 4 years ago

live() does not work with closest()

Reported by: ReneLeonhardt Owned by: john
Priority: minor Milestone: 1.3.2
Component: selector Version: 1.3.1
Keywords: live, closest Cc:
Blocking: Blocked by:

Description

I have a tablesorter where the first column contains a checkbox.

This works: $('table.tablesorter tbody td:first-child').live('click', function(e){alert('clicked')});

This doesn't work: $('table.tablesorter tbody td:first-child :checkbox').closest('td').live('click', function(e){alert('clicked')});

Change History

comment:1 Changed 4 years ago by dmethvin

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

 http://docs.jquery.com/Events/live#typefn

"Live events currently only work when used against a selector."

This is because when the event bubbles up to the document, the selector alone is used to determine whether there is a match. You can't use any chain filters like .closest() or .parent() after the selector.

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.