JQuery.fadeOut .click callback Not working

I am working on an application for downloading images, and everything works fine, except for one error that only occurs in Chrome. I split the problem into one callback that fails.

The problem is that the .fadeOut callback to start .click () does not start. I recreated the simplified version in the violin, which is given below. The first click fires fadeOut, and when fadeOut is finished, the .click trigger fails. Press again. Then it launches a trigger. Any ideas why?

HTML:

<div><input type="file" name="image_file" id="image_file"/></div>

<div class="overlay_wrap">
    Overlast
</div>

<a id="click" href="">Click</a>

JQuery

$(document).ready(function() {
    $("#click").click(function(event) {
        event.preventDefault();
        $('.overlay_wrap').fadeOut(1000, function(event){
            $('#image_file').trigger('click');
        });
    });
});

http://jsfiddle.net/gg2a7/5/

Thanks for the help!

EDIT: did the link to the old script change.

+5
source share
2 answers

, . / .

: <input type="file" /> ( SO/ Google ). Chrome; Firefox , , Safari , IE .

, . <input type="file" /> . - .fadeOut() . / , . , /-, .

$("#click").click(function(event) {
    event.preventDefault();
    $('#image_file').trigger('click');
});

JSFiddle.

, <input type="file" />, <input type="button" />, :

HTML

<input type="button" name="image_file" id="image_file" value="type='button'" />

JS

$("#click").click(function(event) {
        event.preventDefault();
        $('.overlay_wrap').fadeOut(1000, function(){
            $('#image_file').trigger('click');
        });
    });

    $('#image_file').click(function() {
         alert('ok');   
    });

JSFiddle.

: . , , .

$("#click").click(function(event) {
    event.preventDefault();
    $('.overlay_wrap').hide();
    $('#image_file').trigger('click');
});

JSFiddle.

+2

$('.overlay_wrap').fadeOut(1000,complete)

$('.overlay_wrap').fadeOut(1000);
complete();
0

All Articles