簡體   English   中英

如何鏈接多個jquery fancyboxes?

[英]How do I chain multiple jquery fancyboxes?

我在我的Web應用程序中將fancybox用於模態。

在某些情況下,我想在第二個花式盒子已經打開的情況下彈出它。 有人知道這樣做的方法嗎? 我可以在另一個關閉后打開一個,或者兩個都同時在另一個下面打開。

同樣,我在應用程序中使用了jquery和fancybox。

這是一個討論相同問題的相關主題。. 如何在另一個關閉后打開一個Fancybox?

編輯:在討論中, https ://stackoverflow.com/users/139396/okw提供了一個很好的示例

我已將示例放在jsfiddle上: http : //jsfiddle.net/CkK8N/

我自己已經解決了這個問題。

場景:

  • 使用iframe啟動一個fancybox
  • 在打開的fancybox中,打開另一個包含ajax Web服務交付內容的fancybox。

關鍵點

  • 如果使用fancybox和iframe,則需要使用parent。$。fancybox,否則$ .fancybox可以。
  • 加載內容前別忘了顯示活動
  • 加載內容后別忘了調整大小

程式碼片段:

        if (parent) {
        // if in an iframe we need to show activity for the parents' fancybox
        parent.$.fancybox.showActivity();
    }
    else {
        // otherwise show activity for the fancybox of the current window
        $.fancybox.showActivity();
    }       

            // I'm using Ajax to fetch the content but you can fetch it in other ways too
    $.ajax({
        url: "your url goes here",
        type: "POST",
        contenttype: "text/xml; charset=utf-8",
        dataType: "xml",
        data: { "name": "john"},
        success: function (data, textStatus, jqXHR) {

            if (parent) {                   
                // if in an iframe we need to push the content into the parents' fancybox
                parent.$.fancybox($(jqXHR.responseXML).text());
                parent.$.fancybox.resize();
            }
            else {
                // otherwise push the content into the fancybox of the current window
                $.fancybox($(jqXHR.responseXML).text());
                $.fancybox.resize();
            }

        }
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM