Skip to main content

Bug Tracker

Side navigation

#6911 closed bug (fixed)

Opened August 17, 2010 04:03AM UTC

Closed February 18, 2011 06:37PM UTC

Last modified March 19, 2012 09:15PM UTC

.live('click',handler) should not fire on disabled button in IE

Reported by: yoursunny Owned by: danheberden
Priority: high Milestone: 1.5.1
Component: event Version: 1.5
Keywords: Cc:
Blocked by: Blocking:
Description

Take the following snippet:

<div id="a">

<input type="button" disabled="disabled" id="b1" value="button1">

</div>

$(':button','#a').live('click',function(){ });

The live click event does not fire in Firefox 3.6, but fires in IE8 on Win7.

Since the button is disabled, I think the correct implementation should not fire live click event on #b1.

Attachments (1)
Change History (27)

Changed October 15, 2010 04:34AM UTC by snover comment:1

milestone: 1.4.31.next
priority: → high
status: newopen
version: 1.4.21.4.3

Changed October 21, 2010 10:59PM UTC by snover comment:2

milestone: 1.4.41.4.5

Retargeting due to severity of regressions in 1.4.3.

Changed October 22, 2010 05:53AM UTC by snover comment:3

milestone: 1.4.51.4.4

Retargeting for 1.4.4 as per John’s request.

Changed October 22, 2010 06:27AM UTC by snover comment:4

owner: → danheberden
status: openassigned

Changed October 25, 2010 09:19PM UTC by anonymous comment:5

Submitted pull request to disable events on disabled items: http://github.com/jquery/jquery/pull/76

Changed October 25, 2010 09:34PM UTC by danheberden comment:6

Heh, guess it helps to log in before doing that :p Pull req: http://github.com/jquery/jquery/pull/76

Changed October 28, 2010 02:09AM UTC by snover comment:7

milestone: 1.4.41.4.5

Retargeting to next minor release.

Changed November 20, 2010 03:29PM UTC by dmethvin comment:8

Changed November 21, 2010 11:15PM UTC by danheberden comment:9

resolution: fixed
status: closedreopened

Changed November 21, 2010 11:16PM UTC by danheberden comment:10

That commit was backed out - I will provide a new one.

Changed November 22, 2010 12:59AM UTC by danheberden comment:11

Changed November 22, 2010 07:12AM UTC by snover comment:12

status: reopenedassigned

Changed December 06, 2010 09:39PM UTC by john comment:13

resolution: → fixed
status: assignedclosed

Landed.

Changed January 14, 2011 10:20PM UTC by jitter comment:14

milestone: 1.4.51.5

Move fixed tickets to appropriate milestone

Changed February 02, 2011 05:52PM UTC by marksteward@gmail.com comment:15

Is this correct? It seems to me the fix should be to check currentTarget, not target.

Also, it's not limited to IE - it can be reproduced on Chrome 9.0.597.45. See

http://forum.jquery.com/topic/live-inconsistency-with-disabled-buttons.

Changed February 02, 2011 06:04PM UTC by danheberden comment:16

http://jsfiddle.net/danheberden/ZaU4E/ - take it for a spin :)

Changed February 03, 2011 04:12PM UTC by ms7821 comment:17

danheberden: thanks. I think this might really be a separate bug, which is half fixed by your commit.

It's possible to receive events for a disabled <button> element as well as <input type="button">:

http://jsfiddle.net/Fz2F3/ (jQuery 1.4.4)

http://jsfiddle.net/Fz2F3/1/ (jQuery 1.5)

IE7 fires click for all of them, passing the button as the target and currentTarget.

Chrome fires only for the <button> with a child element, passing that as the target. However, currentTarget is set to the button, so changing target.disabled to currentTarget.disabled should extend the fix to include Chrome.

I didn't realise 1.5 had already been released, so I'll open a new ticket specifically for buttons on Chrome.

Mark

Changed February 03, 2011 04:17PM UTC by danheberden comment:18

milestone: 1.51.5.1
resolution: fixed
status: closedreopened
version: 1.4.31.5

Well in the end it's the same root issue, i'll go a head and re-open this one. Thanks for your work!

Changed February 03, 2011 04:18PM UTC by ms7821 comment:19

Ahh, do you want me to delete http://bugs.jquery.com/ticket/8165?

Changed February 03, 2011 04:19PM UTC by danheberden comment:20

#8165 is a duplicate of this ticket.

Changed February 03, 2011 04:20PM UTC by danheberden comment:21

Marked as dup - that'll link them together :)

Changed February 06, 2011 04:09PM UTC by snover comment:22

status: reopenedopen

Changed February 18, 2011 05:37PM UTC by danheberden comment:23

_comment0: While at first glance "currentTarget" sounds like a reasonable fix, it isn't. \ \ The firing event is still the element that is NOT disabled. So this fix would involve checking every click events parents for an element that's disabled. That isn't reasonable, as you can imagine. \ \ So while we can easily check if event.target.disabled, checking the parent just in case isn't as easy. I mean easy as in not penalizing non-disabled actions with a crap load of work. \ \ In this context, if you plan on attaching to elements that might be children of disabled elements then by all means, place that check in your own code. \ 1298051052427514
resolution: → fixed
status: openclosed

actually, just might got it fixed

Changed February 18, 2011 05:44PM UTC by danheberden comment:24

resolution: fixed
status: closedreopened

Changed February 18, 2011 06:15PM UTC by danheberden comment:25

DaveMethvin pummeled me until i saw a way to do it - all better in https://github.com/jquery/jquery/pull/237

Changed February 18, 2011 06:37PM UTC by john comment:26

resolution: → fixed
status: reopenedclosed

Landed.

Changed February 25, 2011 10:08AM UTC by ms7821 comment:27

Awesome to see, thanks danheberden!