Skip to main content

Bug Tracker

Side navigation

#11983 closed bug (cantfix)

Opened June 28, 2012 08:17AM UTC

Closed July 03, 2012 05:07PM UTC

Last modified July 04, 2012 07:32AM UTC

Inconsistent change event on file inputs on IE

Reported by: ( axl ) ( dot ) ( ayco ) ( at ) ( gmail ) ( dot ) ( com ) Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: ie6 ie7 Cc:
Blocked by: Blocking:
Description

Hi guys.

I'm working with jQuery 1.7.2 and its wonderful event binding methods, and I came across a bug.

http://jsfiddle.net/t9qrQ/2/

First of all we assign a change event to an input type=file (with the on method, delegation way). Then if I open the file dialog and select a file the change event triggers the right way. But if I trigger the click for the input, the file dialog opens but no change event is fired.

THIS ONLY HAPPENS ON IE7/8

Could not test on IE6

Works ok on IE9

Works ok on Chrome

Works ok on FF 13

When I tested on FF 3.6 I found that the .click() didn't open the file dialog, so it may be another bug there...

http://jsfiddle.net/t9qrQ/2/

Attachments (0)
Change History (5)

Changed June 29, 2012 08:19AM UTC by ( axl ) ( dot ) ( ayco ) ( at ) ( gmail ) ( dot ) ( com ) comment:1

I discovered that this only happens when I open the input type=file with the jQuery .click() method, not with the browser .click().

I updated the test case : http://jsfiddle.net/t9qrQ/4/

You can take a look at my other bug submission: http://bugs.jquery.com/ticket/11991

Both are about not perfect behavior of the jQuery .click() method, but remember that this ticket isonly related to IE 7/8, and my other ticket is about all browsers.

Changed June 29, 2012 09:20AM UTC by ( axl ) ( dot ) ( ayco ) ( at ) ( gmail ) ( dot ) ( com ) comment:2

I discovered which is the behavior of IE more concisely and I'm freaking...

If I click the input type=file with my mouse, the change event begins working, later if I do browser .click() or jquery .click() the change event keeps working ok.

If I begin with browser .click() or jquery .click() the change event won't fire. If then I click with the mouse the change event gets activated, and if then I do browser .click() or jquery .click() (AFTER CLICKING ALMOST ONE TIME WITH THE MOUSE) the change event keeps working.

Conclusions:

  • input type=file onChange events won't work on IE7/8 until the user manually clicks the input with his mouse almost once, javascript virtual clicks won't mind.
  • this is obvioulsy a bug on IE7/8, so:
  • this shouldn't then be considered a bug submission, but a feature request
  • could jQuery developers create a workaround for this IE bug? I'm thinking about that at this time and I can't imagine how a javascript library could fix that implementation failure.

In my case, I fixed my web app by coding a conditional event:

($.browser.msie&&parseInt($.browser.version)<9)? "click": "change"

var callback = function(){ /* true code here */}

($.browser.msie&&parseInt($.browser.version)<9)? setTimeout(callback, 0): callback();

but this isn't unacceptable for the core code...

Any ideas?

Changed July 03, 2012 05:07PM UTC by dmethvin comment:3

resolution: → cantfix
status: newclosed

There's really no way to fix or fake this. IE doesn't provide the information we need. As you said in the last comment there may be ways for app code to work around the issue, but they're not sufficiently general or consistent that we could include them into core.

Changed July 03, 2012 05:07PM UTC by dmethvin comment:4

keywords: → ie6 ie7

Changed July 04, 2012 07:32AM UTC by ( axl ) ( dot ) ( ayco ) ( at ) ( gmail ) ( dot ) ( com ) comment:5

I suggest adding keywords IE8, and perhaps input file and change.

I wanna add that I read somewhere that the change event on input type files on IE can be replaced by "onPropertyChange", but I couldn't get it to work. could you be intrested in trying it? Maybe if works can suit the consistency requirements for core code, but just a suggestion. Maybe you have already tried that.

Best regards.