Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 11 years ago

#815 closed bug (wontfix)

click event handler for checkbox gets fired twice

Reported by: [email protected] Owned by:
Priority: major Milestone: 1.1.3
Component: event Version: 1.1
Keywords: click trigger input checkbox Cc:
Blocked by: Blocking:


A click event handler that is attached to a checkbox gets executed twice when using $('input[@type="checkbox"]').trigger('click').

Demo: http://stilbuero.de/demo/jquery/trigger.html

Change History (7)

comment:1 Changed 16 years ago by Dave

In Firefox 2.0 yes; in IE7, no.

comment:2 Changed 16 years ago by brandon

I believe this is because Firefox fires the click event when the checkbox is changed (onchange). So, triggering the click event fires the click + change which then fires click again.

comment:3 Changed 16 years ago by john

Resolution: fixed
Status: newclosed

Fixed in SVN rev 1146.

comment:4 Changed 16 years ago by [email protected]

Resolution: fixed
Status: closedreopened

Its still happening with FF 2, WinXP SP2 on Trunk rev 1296 This may be a slight variant of the above but pretty similar

Test case:

<!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>...</title>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

$(document).ready(function() {

$('#todo-list li').bind('click',function() {

This fires twice





</head> <body>

<ol id="todo-list">

<li><label><input type="checkbox" value="1" name="task[1]"> test case</label></li>


</body> </html>

comment:5 Changed 16 years ago by john

need: Test Case

comment:6 Changed 16 years ago by joern

need: Test CaseReview

Added a test in [1589], though it doesn't fail. Manually clicking the checkbox to trigger the event works fine, too.

comment:7 Changed 16 years ago by brandon

Resolution: wontfix
Status: reopenedclosed

The issue happens when clicking the label. The change event would be more suitable and would allow for proper keyboard usage.

Note: See TracTickets for help on using tickets.