Skip to main content

Bug Tracker

Side navigation

#815 closed bug (wontfix)

Opened January 15, 2007 09:28PM UTC

Closed April 25, 2007 11:21PM UTC

Last modified March 15, 2012 04:55PM UTC

click event handler for checkbox gets fired twice

Reported by: klaus.hartl@stilbuer Owned by:
Priority: major Milestone: 1.1.3
Component: event Version: 1.1
Keywords: click trigger input checkbox Cc:
Blocked by: Blocking:
Description

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

Attachments (0)
Change History (7)

Changed January 15, 2007 10:35PM UTC by Dave comment:1

In Firefox 2.0 yes; in IE7, no.

Changed January 16, 2007 03:51PM UTC by brandon comment:2

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.

Changed January 22, 2007 02:43AM UTC by john comment:3

resolution: → fixed
status: newclosed

Fixed in SVN rev 1146.

Changed February 07, 2007 10:39PM UTC by james@netcon comment:4

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

alert('firing...');

});

});

</script>

</head>

<body>

<ol id="todo-list">

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

</ol>

</body>

</html>

Changed March 24, 2007 05:44PM UTC by john comment:5

need: → Test Case

Changed March 25, 2007 12:17PM UTC by joern comment:6

need: Test CaseReview

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

Changed April 25, 2007 11:21PM UTC by brandon comment:7

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.