Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#12288 closed bug (invalid)

"live" / "delegate" bug about ":enabled" filter

Reported by: [email protected] Owned by: [email protected]
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:


If we use "live" or "delegate" to attach an event handler (for example about an ajax panel) and if we use one of related selectors or methods to filter ":enabled" elements and if the result of selector represents to a collection of anchors(link tags) and input buttons or other type of inputs then : "that event handler doesn't work just for links(anchors) and the just reason is checking for :enabled on anchors because anchors doesn't have the ability for enabling or disabling" so finally BOOOM $('[rel*="AjaxElement"]:enabled').live('click', function(e){}) inputs ok, anchors boom

Change History (5)

comment:1 Changed 9 years ago by abbasali hashemian (alix) <[email protected]…>

more information :
browser(firefox 10.0.2)
jQuery version : accident(1.7.1) - test again and bug again(1.8.0)
OS : win7
First accident code : $('[rel*="Async"]:not(:text, :password, select, textarea):not([rel*="NotAsync"])').not('[disabled]').live('click', fun...
Debug reduced codes : yes : alert($('#Nav a').filter('enabled').live('click', fun).length); 13 number of results and fun wasn't triggered

WARNING ! be careful through .click and .live('click' because click works correctly and the problem is .live

comment:2 Changed 9 years ago by sindresorhus

Owner: set to [email protected]
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:3 Changed 9 years ago by dmethvin

Resolution: invalid
Status: pendingclosed

$('[rel*="Async"]:not(:text, :password, select, textarea):not([rel*="NotAsync"])').not('[disabled]').live('click', fun...

The .live method cannot be used in a chain like that, see the documentation. Also, .live is deprecated.

comment:4 Changed 9 years ago by alix

With regard to jQuery Documentation(:enabled) on http://api.jquery.com/enabled-selector/ describing : ".... In other words, the bare $(':enabled') is equivalent to $('*:enabled'), so $('input:enabled') should be used instead. .... "

But in fact the subject is different. Let's take a look:

comment:5 Changed 9 years ago by alix

OK there is no problem with .live because the actual bug is from :enabled selector returning different result against :not(:disabled)
As described in documentation :enabled should be like *:enabled NOT input:enabled Please check the fiddle code :

Last edited 9 years ago by alix (previous) (diff)
Note: See TracTickets for help on using tickets.