2012-05-30 38 views
0

我的jQuery代碼回調的fancybox

$("#div1").load("test1.html") 

$("a#link").fancybox({ 
    'transitionIn' : 'elastic', 
    'transitionOut' : 'elastic', 
    'width'   : 400, 
    'height'  : 200, 
    'overlayOpacity': 0.5, 
    'type'   : 'iframe' 
}); 

.load我的fancybox不工作後。

它工作在test1.html

我該怎麼寫呢?

+0

您是否需要爲test1.html運行.load()? Fancybox不會那麼喜歡它,它不喜歡在ajax內容中運行...... –

回答

2

我不知道的fancybox什麼,但使用負載功能,當數據被異步加載,因此調用加載後什麼可以做之前,它是加載。如果您希望它能夠影響已加載的項目,則應將代碼添加到回調中。

$("#div1").load("test1.html", function() { 
    $("a#link").fancybox({ 
     'transitionIn' : 'elastic', 
     'transitionOut' : 'elastic', 
     'width'   : 400, 
     'height'  : 200, 
     'overlayOpacity': 0.5, 
     'type'   : 'iframe' 
    }); 
})