問題描述
我正在使用fancybox 2.我已經設法通過AJAX 在fancybox 中加載內容.但它會加載整個頁面,我只對特定的 div 感興趣.在 fancybox 1 中,我們可以通過在 ajax 中添加過濾器來做到這一點.但我不確定如何在fancybox 2 中進行過濾.
I am using fancybox 2. I have manage to load content in fancybox via AJAX. But it loads the whole page and I am only interested in specific div. In fancybox 1 we could do that by adding filter in ajax. But I am not sure how to filter in fancybox 2.
如何在fancybox 2 中從AJAX 加載頁面中過濾特定的div?
How to filter specific div from AJAX loaded page in fancybox 2?
$(".fancybox").fancybox({
maxWidth : 800,
maxHeight : 600,
fitToView : false,
width : '70%',
height : '70%',
autoSize : false,
closeClick : false,
openEffect : 'none',
closeEffect : 'none',
type : 'ajax',
'ajax' : {
dataFilter: function(data) {
return $(data).find('#modalArticleContainer')[0];
}
});
Untile ajax 它可以工作但會加載整個頁面,當我添加過濾器時它會停止工作.這就是我之前在 fancybox 1 中所做的.
Untile ajax it works but loads whole page, when I add filter then it stops working. This is how I did previously in fancybox 1.
推薦答案
如果你使用的是最新的(https://github.com/fancyapps/fancyBox/zipball/master),那么有一個技巧可以加載特定元素來自 ajax 響應 -
If you are using the latest (https://github.com/fancyapps/fancyBox/zipball/master), then there is a trick to load specific element from the ajax response -
<a href="mypage.html #my_id" class="fancybox fancybox.ajax">Load ajax</a>
$(".fancybox").fancybox();
這篇關于使用fancybox在模態窗口中加載特定的div的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!