Skip to main content

Bug Tracker

Side navigation

#12686 closed bug (wontfix)

Opened October 09, 2012 12:57PM UTC

Closed October 16, 2012 01:39PM UTC

Live change event is not fired on IE8 when input is focused

Reported by: joachim.e.rousseau+jquery@gmail.com Owned by: elgreg
Priority: high Milestone: None
Component: event Version: 1.8.2
Keywords: ie7 ie8 Cc:
Blocked by: Blocking:
Description

When 'change' event is bound whith jQuery.live() on a text input that has focus (carret blinking inside, focus() explicitly called), the 'change' event isn't fired on first value change.

I just added an explicit focus an an example from bug #5851 to show this one.

Expected behaviour (FF/Chrome OK) : when DOM is ready, the text input has focus. If you start typing text then leaving it whith tab or clicking outside, the alert shows.

IE8 (KO) behaviour : when DOM is ready, the text input has focus BUT if you start typing text then leaving it, no alert is visible. To get the alert, you have to get back into the text field then modify its value, then leaving it again.

Reported against jQuery 1.7.2 and 1.8.2.

Attachments (0)
Change History (7)

Changed October 09, 2012 12:59PM UTC by anonymous comment:1

Don't know how to attache the example, here is the code :

<html>
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script>
      jQuery(function() {
      	jQuery('#txt0')[0].focus()
        $('.textbox').live('change', function (event) {
          alert("Changed!");
        });
      });
    </script>
  </head>
  <body>
    <input id="txt0" type="text" class="textbox"/>
  </body>
</html>

Changed October 09, 2012 01:22PM UTC by dmethvin comment:2

keywords: → ie7 ie8
status: newopen

Confirmed in IE8: http://jsfiddle.net/VUY3g/

Works in bare DOM: http://jsfiddle.net/VUY3g/1/

Or bare DOM with jQuery loaded: http://jsfiddle.net/VUY3g/2/

Or with attachEvent instead of DOM0 handler: http://jsfiddle.net/VUY3g/3/

Changed October 09, 2012 01:24PM UTC by dmethvin comment:3

Clarifying ... the event is firing, but for these cases we need to manually bubble and we're not for some reason.

Changed October 09, 2012 02:00PM UTC by anonymous comment:4

Replying to [comment:3 dmethvin]:

Clarifying ... the event is firing, but for these cases we need to manually bubble and we're not for some reason.

Yes, I forgot to mention it works with bind() and on() ''without'' delegate.

The handler is not called only if bound with live() or on() ''with'' delegate, and only for the very first change.

Changed October 15, 2012 05:52PM UTC by timmywil comment:5

component: unfiledevent
priority: undecidedhigh

Changed October 15, 2012 06:00PM UTC by elgreg comment:6

owner: → elgreg
status: openassigned

Changed October 16, 2012 01:39PM UTC by elgreg comment:7

resolution: → wontfix
status: assignedclosed

Took a look at this with @dmethvin. The internals of jquery spoofing event bubbling for change events in old IE mean you need to focus ''after'' attaching the live event. Simply moving the focus to after the event is attached should fix the issue:

jsfiddle: http://jsfiddle.net/elgreg/6jrU3/

Marking as won't fix as generally a delegated event can generally be attached prior to focus.