Bug Tracker

Modify

Ticket #10873 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

live does not work with elements got from using each function

Reported by: anonymous Owned by: anonymous
Priority: low Milestone: None
Component: event Version: 1.7.1
Keywords: Cc:
Blocking: Blocked by:

Description

example:

$('a').each(function(i. elt) {

$(elt).live('click', function() {

console.log('Not a bug!!');

});

});

Change History

comment:1 Changed 2 years ago by addyosmani

  • Owner set to anonymous
  • Priority changed from undecided to low
  • Status changed from new to pending
  • Component changed from unfiled to event

Thanks for submitting a ticket to the jQuery bug tracker. Could you please also provide us with a complete test case on jsFiddle that reproduces the issues you're experiencing? It would also be great if you could test with jQuery edge.

comment:2 Changed 2 years ago by ajpiano

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

This is documented behaviour, live does not work against arbitrary collections, including those made from DOM element references, it only works directly after a string selector.

"Chaining methods is not supported. For example, $("a").find(".offsite, .external").live( ... ); is not valid and does not work as expected."

 http://api.jquery.com/live/

Furthermore, 'a' elements that are already on the page and then trying to make a .live call against them doesn't really make much sense, as it kind of defeats the point of "working with future elements" conceptually.

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.