使用fancybox在模态窗口中加载特定的div

load specific div in modal window using fancybox(使用fancybox在模态窗口中加载特定的div)
本文介绍了使用fancybox在模态窗口中加载特定的div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在使用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

ajax请求获取json数据并处理的实例代码 $.ajax({ type: 'GET', url: 'https://localhost:44369/UserInfo/EditUserJson',//请求数据 data: json,//传递数据 //dataType:'json/text',//预计服务器返回的类型 timeout: 3000,//请求超时的时间 //回调函数传参 suc
append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href
Rails 3.1 ajax:success handling(Rails 3.1 ajax:成功处理)
ExecJS::ProgramError: SyntaxError: Reserved word quot;functionquot;(ExecJS::ProgramError: SyntaxError: 保留字“function)
Infinite scroll and will_paginate appending the #39;next page#39; of items multiple times(无限滚动和 will_paginate 多次附加项目的“下一页)
Ajax call in rails 3.2.3 with will_paginate gem(使用 will_paginate gem 在 Rails 3.2.3 中调用 Ajax)