Ticket #8040 (closed bug: duplicate)
Bind two "change" events in IE will be fired twice
| Reported by: | anonymous | Owned by: | dmethvin |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | event | Version: | 1.5 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description (last modified by jitter) (diff)
In IE, when bind two "change" events to a textbox, and the first event will change the value of the textbox (e.g. toUpper, formatDate), then the second event will be fired twice.
Test code:
<input name="str1" id="str1" value="str1">
<script>
function toUpper() {
document.getElementById("str1").value =
document.getElementById("str1").value.toUpperCase();
}
function changeTest() {
alert(1);
}
jQuery("#str1").bind("change", toUpper);
jQuery("#str1").bind("change", changeTest);
</script>
Test result:
- In IE(both IE6 and IE8), when input "abc" into str1, "1" will be alerted twice.
- In Firefox, it is OK, only alert once.
Change History
comment:1 Changed 2 years ago by jitter
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to event
- Description modified (diff)
comment:3 Changed 2 years ago by jitter
- Version changed from 1.4.4 to 1.5
Test case adapted from #8269
http://jsfiddle.net/jitter/5zhP8/6/ without jQuery
http://jsfiddle.net/jitter/Z9EeB/ with jQuery
So not related to two handlers but that changing the value inside the change handler triggers another change event when using jQuery.
comment:5 Changed 21 months ago by dmethvin
- Owner set to dmethvin
- Priority changed from low to high
- Status changed from open to assigned
- Milestone changed from 1.next to 1.7
This should be fixed in 1.7, I'll recheck once it lands.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

This bug looks valid after a first quick check.
test case trying to simulate all of this without jQuery.
test case using jQuery.bind showing the double call behavior.
Maybe something is bogus in the special handling of the change event to make it bubble in IE.