开发者

Live change() for ajax generated input type file in Internetexplorer < 9.0

开发者 https://www.devze.com 2023-03-25 06:54 出处:网络
I am trying to to trigger a change event in a input type file Box. This Box is generated by ajax, each time a file was uploaded. This is my Function:

I am trying to to trigger a change event in a input type file Box. This Box is generated by ajax, each time a file was uploaded. This is my Function:

jQuery("#file1").live('change', function(){
    jQuery('.pic_upload').fadeIn(); 
});

This works in all browsers including Ie 9.0. In IE < 9.0 the change event is not getting triggered properly. So I have this function:

jQuery("#file1").bind((jQuery.browser.msie && jQuery.browser.version < 9) ? 'propertychange' : 'change',
                               function()开发者_运维百科{ 
                                   jQuery('.pic_upload').show();
                     });

This works good, in IE but only for the first inout type file tag. If, after the first upload is completed, this input field get hidden and a new one shows up. That's the reason, why I need the live() instead of bind().

The problem: I can not use live(), because it does not work in IE. I also can not use bind(), because this works only for the non ajax generated upload boxes.

Is there any workaround for this problem?


One idea would be to wrap the .bind() in a function and call the function after your ajax call completes.

0

精彩评论

暂无评论...
验证码 换一张
取 消