Skip to main content

Bug Tracker

Side navigation

#8040 closed bug (duplicate)

Opened January 24, 2011 03:16PM UTC

Closed September 21, 2011 03:18AM UTC

Last modified March 13, 2012 06:17PM UTC

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:
Blocked by: Blocking:
Description

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.
Attachments (0)
Change History (8)

Changed January 28, 2011 01:33PM UTC by jitter comment:1

component: unfiledevent
description: 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. 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.
priority: undecidedlow
status: newopen

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.

Changed February 14, 2011 02:08PM UTC by jitter comment:2

#8269 is a duplicate of this ticket.

Changed February 14, 2011 02:15PM UTC by jitter comment:3

version: 1.4.41.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.

Changed March 29, 2011 03:11PM UTC by anonymous comment:4

Any updates on this bug?

Changed September 08, 2011 06:40PM UTC by dmethvin comment:5

milestone: 1.next1.7
owner: → dmethvin
priority: lowhigh
status: openassigned

This should be fixed in 1.7, I'll recheck once it lands.

Changed September 21, 2011 03:18AM UTC by dmethvin comment:6

resolution: → duplicate
status: assignedclosed

Changed September 21, 2011 03:18AM UTC by dmethvin comment:7

Duplicate of #10132.

Changed September 27, 2011 04:05AM UTC by dmethvin comment:8

milestone: 1.7