jQuery同步调用
我结合了两个jQuery插件,Fancybox和Embeddely(如jQuery oembed) 在Fancybox onStart事件中,我获取链接的url,调用oembed服务并将响应(视频)推回到lightbox中 好吧,至少这是我想要发生的:)我从oembed提供者那里得到了一个响应,但我认为onStart函数在发生这种情况时已经完成了 守则:jQuery同步调用,jquery,fancybox,oembed,Jquery,Fancybox,Oembed,我结合了两个jQuery插件,Fancybox和Embeddely(如jQuery oembed) 在Fancybox onStart事件中,我获取链接的url,调用oembed服务并将响应(视频)推回到lightbox中 好吧,至少这是我想要发生的:)我从oembed提供者那里得到了一个响应,但我认为onStart函数在发生这种情况时已经完成了 守则: $('a').fancybox({ type: 'html', onStart: function(selectedArray
$('a').fancybox({
type: 'html',
onStart: function(selectedArray, selectedIndex, selectedOpts) {
var url = selectedArray[selectedIndex].href;
$.embedly(url, {
success: function (oembed, dict) {
selectedOpts.content = oembed.html;
}
});
}
});
似乎我需要同步处理呼叫
谢谢本试试这个
$('a').each(function(i, a){
var url = a.href, $a = $(a);
$.embedly(url, {
success: function (oembed, dict) {
$a.fancybox({
type: 'html',
onStart: function(selectedArray, selectedIndex, selectedOpts) {
selectedOpts.content = oembed.html;
}
});
}
}
});
});
不幸的是,这意味着我无法在gallery模式下加载链接集合。这就是为什么我需要在元素数组上调用fancybox并覆盖onstart中的内容。