douyue1998 2012-04-27 03:38
浏览 38
已采纳

使用Jquery FancyBox包含DOM

I am trying to use the Fancy Box 2 plugin (fancyapps.com).

All is well except I cannot figure out how to include a DOM element properly.

I am calling this after a form submit that is returning information via ajaxform and validation. documentation says to use the following for dom.

//DOM element:

$.fancybox( $("#inline"), {
    title : 'Custom Title'
});

Now if i create an id on the page in a div it doesn't pull it. Also the div shows.

I tried using the other method (custom object)

$.fancybox({
    href: 'example.jpg',
    title : 'Custom Title'
});

and it does not seem to work with php files. I am trying to populate the lightbox with information from a php file but i get error loading content.

  • 写回答

3条回答 默认 最新

  • dsz90288 2012-04-27 03:57
    关注

    You should probably use ajax() in here.

    As I look into the FancyBox plugin, it does support ajax.

    $("#various3").fancybox({
        ajax: {
            type: "POST",
            data: 'mydata=test'
        }
    });​
    

    HTML

    <li><a id="various3" href="/data/login.php">Ajax - passing custom data</a></li>

    All of these where based on its demo's source code. Demo page & http://fancybox.net/js/.

    UPDATE:

    I did a quick test using fancyBox version 2, pertaining your question.

    I achieve to pull the ajax contents:

    $(document).ready(function() {
        $('.fancybox').fancybox({
            title: 'Custom Title'
        });
    });​
    

    HTML

    <a class="fancybox fancybox.ajax" href="ajax.txt">Show content</a>
    <div id="content">
    </div>
    

    I've noticed that the important part in here is naming your class to class="fancybox fancybox.ajax".

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵