0

Fancybox と Embedly (jQuery oembed など) の 2 つの jQuery プラグインを組み合わせています。

Fancybox の onStart イベントで、リンクの URL を取得し、oembed サービスを呼び出して、応答 (ビデオ) をライトボックスにプッシュします。

少なくともそれが私が望んでいることです:) oembedプロバイダーから応答が返ってきましたが、これが発生するまでにonStart関数はすでに完了していると思います。

コード:

$('a').fancybox({
    type: 'html',
    onStart: function(selectedArray, selectedIndex, selectedOpts) {
            var url = selectedArray[selectedIndex].href;
            $.embedly(url, {
                success: function (oembed, dict) {
            selectedOpts.content = oembed.html;
                }
            });
    }
});

呼び出しを同期的に処理する必要があるようですか?

ありがとう
ベン

4

1 に答える 1

-1

これを試して

$('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;

                               }
                     });
                   }

                }
            });
});
于 2011-06-28T17:35:56.590 に答える