Skip to main content

Bug Tracker

Side navigation

#12288 closed bug (invalid)

Opened August 14, 2012 08:00AM UTC

Closed August 14, 2012 12:48PM UTC

Last modified August 14, 2012 01:47PM UTC

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

Reported by: alixniv@gmail.com Owned by: alixniv@gmail.com
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:
Description

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

Attachments (0)
Change History (5)

Changed August 14, 2012 08:31AM UTC by abbasali hashemian (alix) <alixniv@gmail.com> comment:1

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

Changed August 14, 2012 09:55AM UTC by sindresorhus comment:2

owner: → alixniv@gmail.com
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.

Changed August 14, 2012 12:48PM UTC by dmethvin comment:3

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.

Changed August 14, 2012 01:44PM UTC by alix comment:4

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:

http://jsfiddle.net/RJ8tb/

Changed August 14, 2012 01:47PM UTC by alix comment:5

_comment0: OK there is no problem with .live because the actual bug is from :enabled selector[[BR]] \ Please check the fiddle code :[[BR]] \ [http://jsfiddle.net/RJ8tb/] \ 1344952336756793

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 :

http://jsfiddle.net/RJ8tb/