简体   繁体   中英

Fancybox asynchronous behavior?

I'm having an issue with fancybox. When I load the fancybox, the viewport darkens like normal but it seems that the next line of code is running before my fancybox completely loads.

Ex:

 alert("first");
    jQuery.fancybox({
        'href' : 'form.html',
        'width' : '30%',
        'height' : '50%',
        'type' : 'iframe'
    });
alert("done");

When my codes runs, first is alerted, then the viewport darkens and then done is alerted, and then my fancybox loads.

Is there a way to stop this asynchronous behavior and instead change it so that nothing after the fancybox code will execute until after fancybox closes?

Thanks!

There's no way to "pause" the script for the fancybox execution, you have to put the alert in the onClosed callback:

alert("first");
jQuery.fancybox({
    'href' : 'form.html',
    'width' : '30%',
    'height' : '50%',
    'type' : 'iframe',
    'onClosed': function(){ alert(done)}
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM