Bug Tracker

Modify

Ticket #8040 (closed bug: duplicate)

Opened 2 years ago

Last modified 15 months ago

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)

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 2 years ago by jitter

#8269 is a duplicate of this ticket.

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:4 Changed 2 years ago by anonymous

Any updates on this bug?

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.

comment:6 Changed 20 months ago by dmethvin

  • Status changed from assigned to closed
  • Resolution set to duplicate

comment:7 Changed 20 months ago by dmethvin

Duplicate of #10132.

comment:8 Changed 20 months ago by dmethvin

  • Milestone 1.7 deleted

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.