Side navigation
#5997 closed bug (patchwelcome)
Opened February 01, 2010 09:38AM UTC
Closed April 01, 2011 12:50AM UTC
Last modified March 15, 2012 10:49AM UTC
jQuery change event placed on file input inconsistent between Firefox & IE
Reported by: | wbharding | Owned by: | john |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | event | Version: | 1.4.4 |
Keywords: | neededdocs | Cc: | |
Blocked by: | Blocking: |
Description
I recently upgraded to jQuery 1.4 from 1.2.x and have found that the following code, which previously worked across all browsers, no longer works seamlessly in Internet Explorer:
<form id="myform">
<input type="file">
</form>
...
$('#myform input).change(function() { alert("Someone picked a file") });
...
In Firefox, this code continues to work like it did prior to 1.4, namely, as soon as the user picks a file, the change event fires. But in IE 7 (the only IE I've tested it in) the change event no longer fires, unless/until I click inside the browser window after choosing my file. I'm guessing it has something to do with the event not firing until something (not sure what... maybe the page itself?) gets focus.
Expected behavior would be for the change event to fire immediately in IE after a file has been chosen, just as it does in FF, and it did in jQuery prior to 1.4.
Attachments (0)
Change History (9)
Changed February 01, 2010 02:16PM UTC by comment:1
owner: | brandon → john |
---|---|
status: | new → assigned |
version: | 1.4 → 1.4.1 |
Changed February 13, 2010 09:42AM UTC by comment:2
I landed a temporary fix for this:
http://github.com/jquery/jquery/commit/467063a2e25bae25adfa2e9ab789c62e241c9c56
There definitely needs to be more investigation here - the file input control behaves in a very non-traditional manner, it's not entirely clear what event(s) get triggered when it's interacted with.
Changed November 17, 2010 06:29PM UTC by comment:3
milestone: | 1.4.2 → 1.5 |
---|---|
version: | 1.4.1 → 1.4.4 |
Changed November 17, 2010 06:33PM UTC by comment:4
_comment0: | #7544 is a duplicate of this ticket. → 1290018852884900 |
---|---|
_comment1: | #7544 is a duplicate of this ticket. \ \ Adapted [http://jsfiddle.net/DHy7X/5/ test case] from #7544 → 1290018923142395 |
Changed December 23, 2010 02:33PM UTC by comment:6
http://jsfiddle.net/YRuaX/1/ (bind) - work properly in ie8
http://jsfiddle.net/YRuaX/2/ (live) - doesn't work properly in ie8
Changed April 01, 2011 12:50AM UTC by comment:7
keywords: | → needsdocs |
---|---|
resolution: | → patchwelcome |
status: | assigned → closed |
The native change event doesn't bubble in IE, but we use heroic efforts to bubble a fake-change event for other input types. We aren't able to do that here which means it cannot be used in a .live()
binding.
If anyone can determine a way to create a bubbled change event in IE6/7/8 please contact us and we can discuss whether the fix could be incorporated into jQuery core.
Changed June 13, 2011 05:07AM UTC by comment:8
keywords: | needsdocs → neededdocs |
---|
I've recently documented this here: http://api.jquery.com/live/
Changed August 25, 2011 05:35PM UTC by comment:9
I have documented that here
http://alexturpin.net/jquery.html
And this SO answer seems to be the key to make it work:
http://stackoverflow.com/questions/2389341/jquery-change-event-to-input-file-on-ie/2876677#2876677
Hmm, I'll have to check in to this - not sure if this is something that we tested for in the new change implementation.