簡體   English   中英

在Fancybox onClosed事件上的Fancybox中加載新內容

[英]Load new content in Fancybox on Fancybox onClosed event

我遇到了Fancybox windows的問題。 我使用fancybox在我的頁面上顯示隱藏div的內容(下面的“.popup”fancybox)。 在該內容中,有一個名為#exemple的新fancybox內容的鏈接。 當我點擊第一個fancybox中的鏈接時,它會加載第二個fancybox內容(iframe - 這很好)。 但是當用戶點擊第二個fancybox的關閉按鈕時,我想回到第一個fancybox。

我試過“onClosed”事件,但它不起作用......

有沒有辦法做到這一點?

預先感謝您的幫助!

這是我使用的代碼:

$("#exemple").fancybox({
    'width'             : '100%',
    'height'            : '100%',
    'titleShow'         : true,
    'titlePosition'     : 'over',
    'titleFormat'       : formatTitle,
    'autoScale'         : false,
    'centerOnScroll'    : true,
    'type'              : 'iframe',
    'onClosed'          : function() {
            alert('test');
            $(".popup").trigger('click');
        } 
});

$(".popup").fancybox({
    'autoScale'         : false,
    'centerOnScroll'    : true
});

// and here is the HTML code to trigger the hidden div:
<a style="font-weight: bold;" href=#data class=popup>our data</a>

//and the HTML code of the link inside the hidden div that gets displayed in the fancybox:
<a id=exemple title="xxx" href=xxx.php?id=xxx>link</a>

我正在使用相同的東西,onClosed沒有工作。 經過大量研究后,我發現存在某種版本問題,並且onClosed適用於舊版本的花式框。 對我有用的另一種方法是使用beforeClose而不是onClosed。

'beforeClose':function(){alert('test')},

這可能對一些讀者有所幫助。

如果你有一個jsFiddle工作,它會有所幫助,但首先嘗試在setTimeout包裝onClosed函數代碼。 零時間就足夠了:

'onClosed' : function() {
    setTimeout(function(){
        $(".popup").trigger('click');
    }, 0);
} 
'onClosed'=> 'js:function() { alert("test") }',

注意:我們需要輸入“js:”

我自動調用fancybox(使用擴展名)

這對我來說很好

暫無
暫無

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

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