Bug Tracker

Opened 13 years ago

Closed 12 years ago

Last modified 11 years ago

#6911 closed bug (fixed)

.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)

jquery-live-disabled.htm (810 bytes) - added by yoursunny 13 years ago.
reproduce code

Download all attachments as: .zip

Change History (28)

Changed 13 years ago by yoursunny

Attachment: jquery-live-disabled.htm added

reproduce code

comment:1 Changed 13 years ago by snover

Milestone: 1.4.31.next
Priority: high
Status: newopen
Version: 1.4.21.4.3

comment:2 Changed 13 years ago by snover

Milestone: 1.4.41.4.5

Retargeting due to severity of regressions in 1.4.3.

comment:3 Changed 13 years ago by snover

Milestone: 1.4.51.4.4

Retargeting for 1.4.4 as per John’s request.

comment:4 Changed 13 years ago by snover

Owner: set to danheberden
Status: openassigned

comment:5 Changed 13 years ago by anonymous

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

comment:6 Changed 13 years ago by danheberden

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

comment:7 Changed 13 years ago by snover

Milestone: 1.4.41.4.5

Retargeting to next minor release.

comment:8 Changed 13 years ago by dmethvin

Resolution: fixed
Status: assignedclosed

comment:9 Changed 13 years ago by danheberden

Resolution: fixed
Status: closedreopened

comment:10 Changed 13 years ago by danheberden

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

comment:12 Changed 13 years ago by snover

Status: reopenedassigned

comment:13 Changed 12 years ago by john

Resolution: fixed
Status: assignedclosed

Landed.

comment:14 Changed 12 years ago by jitter

Milestone: 1.4.51.5

Move fixed tickets to appropriate milestone

comment:15 Changed 12 years ago by marksteward@…

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.

comment:16 Changed 12 years ago by danheberden

comment:17 Changed 12 years ago by ms7821

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

comment:18 Changed 12 years ago by danheberden

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!

comment:19 Changed 12 years ago by ms7821

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

comment:20 Changed 12 years ago by danheberden

#8165 is a duplicate of this ticket.

comment:21 Changed 12 years ago by danheberden

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

comment:22 Changed 12 years ago by snover

Status: reopenedopen

comment:23 Changed 12 years ago by danheberden

Resolution: fixed
Status: openclosed

actually, just might got it fixed

Last edited 12 years ago by danheberden (previous) (diff)

comment:24 Changed 12 years ago by danheberden

Resolution: fixed
Status: closedreopened

comment:25 Changed 12 years ago by danheberden

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

comment:26 Changed 12 years ago by john

Resolution: fixed
Status: reopenedclosed

Landed.

comment:27 Changed 12 years ago by ms7821

Awesome to see, thanks danheberden!

Note: See TracTickets for help on using tickets.