【问题标题】:Fancybox not working with jQuery tabsFancybox 不适用于 jQuery 选项卡
【发布时间】:2013-04-30 18:23:16
【问题描述】:

我的网站上有 Fancybox,例如这里,向下滚动到海洋探索照片库:

http://www.sea.edu/academics/oe

我已经在页面的测试版本中添加了 jQuery 选项卡,它可以正常工作,但是现在其中一个选项卡中的 FancyBox 无法正常工作。单击的图像在新窗口中打开。我猜 FancyBox 功能没有在选项卡中激活,但不知道如何修复它。查看非工作页面的示例,在“照片库”选项卡中包含画廊:

http://www.sea.edu/academics/oe_testing

这是在其他页面上工作的功能:

<script type="text/javascript">
    $(document).ready(function() {
    $("a[rel=fancygallery]").fancybox({
            'transitionIn'      : 'none',
            'transitionOut'     : 'none',
            'titlePosition'     : 'over',
            'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
                return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
            }
        });

    });
</script>

我已更改“_testing”页面以删除对不同版本的 jQuery 库的引用,但这并没有解决问题。经过一番搜索,我尝试更改为这个,仍然没有运气:

 <script type="text/javascript">
    $("#OEtabs-3").each(function() {
    $("a[rel=fancygallery]").fancybox({
            'transitionIn'      : 'none',
            'transitionOut'     : 'none',
            'titlePosition'     : 'over',
            'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
                return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
            }
        });

    });
</script>

非常感谢任何建议!

【问题讨论】:

标签: jquery fancybox


【解决方案1】:

fancybox 1.3.4 使用的已弃用的 jQuery.browser msie 属性存在问题(另请参阅 Error jquery-ui draggable Cannot read property 'msie') 所以你必须降级到jQuery 1.8.3 或更好地使用新的fancybox 2(但请注意此处的非商业许可)。

在此处查看带有jQuery 1.8.3fancybox 1.3.4 的小演示:http://jsfiddle.net/JUtz2/ 以及带有jQuery 1.9.1fancybox 2.1.4 的版本:http://jsfiddle.net/M9jUm/1/

【讨论】:

  • @Lauren:更多关于这里的问题stackoverflow.com/q/14344289/1055987 帖子包括可能的解决方法和/或可与 jQuery v1.9+ 一起使用的 fancybox v1.3.4 补丁文件
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-31
  • 2014-02-12
  • 1970-01-01
相关资源
最近更新 更多