Bug Tracker

Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

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

Description (last modified by jitter)

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 (8)

comment:1 Changed 9 years ago by jitter

Component: unfiledevent
Description: modified (diff)
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.

comment:2 Changed 9 years ago by jitter

#8269 is a duplicate of this ticket.

comment:3 Changed 9 years ago by jitter

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.

comment:4 Changed 9 years ago by anonymous

Any updates on this bug?

comment:5 Changed 8 years ago by dmethvin

Milestone: 1.next1.7
Owner: set to dmethvin
Priority: lowhigh
Status: openassigned

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

comment:6 Changed 8 years ago by dmethvin

Resolution: duplicate
Status: assignedclosed

comment:7 Changed 8 years ago by dmethvin

Duplicate of #10132.

comment:8 Changed 8 years ago by dmethvin

Milestone: 1.7
Note: See TracTickets for help on using tickets.