Bug Tracker

Modify

Ticket #5313 (closed bug: invalid)

Opened 4 years ago

Last modified 4 years ago

In IE 7/8, the "change" event does not fire when a form element is changed.

Reported by: edelgadom Owned by:
Priority: major Milestone: 1.4
Component: event Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

Hello,

Given this form:

    <form action="" method="get" accept-charset="utf-8">
        <select name="some_name">
            <option value="option1">option1</option>
            <option value="option2">option2</option>
        </select>
    </form>

And this div:

    <div id="log"></div>

The following code works as expected in Safari 4.0.3 and Firefox 3.5.3, but does not in IE 7 or 8:

  $("form").change(function(){
    $("#log").append("<p>The form has changed</p>");
  });

Seems like in IE, the change event is not propagated or bubbled up to the form element; therefore the code inside the change event block does not get executed.

The same behavior is present using this style of event binding:

  $("form").bind("change", function(e){ ... });

It is only when you change your selector to:

  $("form :input").change(function(){ ... });

That the change event is detected by IE. Of course, the issue with this, is that only those static input elements will be bound to these event listener. Any generated form elements will need to be bound again (so not using event bubbling anymore).

I was expecting the selector to behave the same in IE as in Firefox and Safari. I'm attaching an example. Use it on IE and Firefox please.

Thanks in advance,

Enrique

Attachments

jquery_form_test.html Download (905 bytes) - added by edelgadom 4 years ago.

Change History

Changed 4 years ago by edelgadom

comment:1 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid
  • Component changed from unfilled to event

Since there is no change event on the form itself, you are anticipating that IE will bubble the change events fired by the elements it contains. The problem is that IE does not bubble the change event, contrary to what the W3C spec says. Listen for change events on the form elements directly.

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.