#815 closed bug (wontfix)
click event handler for checkbox gets fired twice
Reported by: | 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').
Change History (7)
comment:1 Changed 16 years ago by
comment:2 Changed 16 years ago by
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:4 Changed 16 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
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>
comment:5 Changed 16 years ago by
need: | → Test Case |
---|
comment:6 Changed 16 years ago by
need: | Test Case → Review |
---|
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
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
The issue happens when clicking the label. The change event would be more suitable and would allow for proper keyboard usage.
In Firefox 2.0 yes; in IE7, no.