开发者

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',
     开发者_如何学JAVA   '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)}
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜