jquery - FancyBox 从多个链接打开同一个画廊

标签 jquery fancybox-2

当我单击“.fancybox-button”时,如何打开与“.fancybox”打开的同一个画廊,同时保持相同的精美框设置?

<div class="custom-thumbnail"><a class="fancybox" rel="group" href="Gallery/Image3.jpg"><img title="Bird Caption" src="Gallery/_t/testImage3_jpg.jpg"></a></div>
<div class="custom-caption"><a class="fancybox-button"  rel="fancybox-button" href="Gallery/testImage3.jpg">Click here to open gallery</a></div>

这是我管理 fancybox 属性的代码

        jQuery(".fancybox").fancybox({
        maxWidth    : 800,
        maxHeight   : 600,
        fitToView   : false,
        width       : '100%',
        height      : '100%',
        title: this.title,
        wmode: 'transparent',
        allowfullscreen   : 'true',
        allowscriptaccess : 'always',
        beforeLoad: function() {
            this.title = jQuery(this.element).find('img').attr('title');
        },
        next : {
            13 : 'left', // enter
            34 : 'up',   // page down
            39 : 'left', // right arrow
            40 : 'up'    // down arrow
        },
        prev : {
            8  : 'right',  // backspace
            33 : 'down',   // page up
            37 : 'right',  // left arrow
            38 : 'down'    // up arrow
        },
        close  : [27], // escape key

        helpers:  {
            title : {
                type : 'inside' // 'float', 'inside', 'outside' or 'over'
            },
            overlay : {
                showEarly : false
            },
            thumbs : {
                width: 50,
                height: 50
            }
        }
    });

最佳答案

这对我有用。你们觉得这个解决方案怎么样?

jQuery('.fancybox-button').click(function(){
        jQuery(this).parent().prev().find('.fancybox').trigger('click');
        return false;
    });

关于jquery - FancyBox 从多个链接打开同一个画廊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30087856/

相关文章:

jquery - ajax函数不起作用

jquery - NodeJS 不会将数据返回给 jQuery.getJSON

JQuery - Slick Carousel 和 Fancybox 冲突

javascript - 了解基本的 JavaScript 逻辑

jquery - fancybox 2 画廊的幻灯片,包含图像和视频,但等待视频完成

javascript - 如何使用 fancybox 2 创建响应式弹出窗口?

jQuery fancyBox 无法使用标题脚本

Jquery如何隐藏工具提示验证消息

javascript - 当搜索值是动态时,如何获取包含特定文本的 div 的计数?

jquery - 如何在 fancybox V2 中为 iframe 设置不同的高度/宽度?