在一个项目中同时使用Bootstrap和Fancybox

4

我在一个项目中同时使用Bootstrap和Fancybox,引入方式如下:

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="fancybox/jquery.fancybox-1.3.4.pack.js"></script>

文件存在,Chrome已经包含了它们。
创建Fancybox元素时:
$(document).ready(function() {
    [...]

    jQuery("a.fancy").fancybox({
        'transitionIn'  : 'none',
        'transitionOut' : 'none'    
    });
});

JS抛出了一个错误:

Uncaught TypeError: Cannot read property 'msie' of undefined jquery.fancybox-1.3.4.pack.js:18
Uncaught TypeError: Object [object Object] has no method 'fancybox'

Bootstrap功能正在运行。

这是一个命名空间的问题吗?


1
可能是Fancybox不支持jQuery v1.9.0的重复问题。 - JFK
1
你正在使用 http://code.jquery.com/jquery-latest.js,所以请查看 https://dev59.com/fWYq5IYBdhLWcg3woB0W。 - JFK
2个回答

2
在调用fancybox之前,DOM是否已经加载?如果没有,请尝试以下操作:
$(document).ready(function() {
    $('a.fancy').fancybox({
        'transitionIn'  : 'none',
        'transitionOut' : 'none'
    });
});

0

我刚通过bundle update得到了这个。

看起来最新版本的jQuery不再支持($.browser)。jQuery文档建议使用Modernizr

我使用了this,它运行良好。

jQuery 1.9文档


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接