Bug Tracker

Modify

Ticket #11845 (closed bug: invalid)

Opened 12 months ago

Last modified 12 months ago

"live" inconsistent behavior with

Reported by: ( axl ) ( dot ) ( ayco ) ( at ) ( gmail ) ( dot ) ( com ) Owned by:
Priority: low Milestone: None
Component: event Version: 1.7.2
Keywords: Cc:
Blocking: Blocked by:

Description

Good morning.

I have found a bug using a multiple selector nested under a second+parameter selector when you later use live().

It's simple, if you use a selector like this $(".foo, .bar", baz); selects all .foo and .bar inside baz,

but if you use that selector to attach events with live() $(".foo, .bar", baz).live("click", function(){alert("yeah");}); attaches the event to all .foo inside baz, and TO ALL .bar IN THE DOCUMENT

You can test it here:  http://jsfiddle.net/7eawe/1/ Tested under Chrome 19, FF12, IE8 and IE8 in IE7 compatibility mode.

Regards

Change History

comment:1 Changed 12 months ago by sindresorhus

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to event

From live() docs:

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

$(".foo, .bar", baz); is the same thing as doing $(baz).find(".foo, .bar"), and thus not supported.

Also, please use delegation instead of live.

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.