【问题标题】:Using Bootstrap & Fancybox in a single project在单个项目中使用 Bootstrap 和 Fancybox
【发布时间】:2012-12-30 04:50:28
【问题描述】:

我在单个项目中使用 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'

(引导函数正在工作)

这是命名空间问题吗?

【问题讨论】:

标签: jquery-plugins twitter-bootstrap fancybox javascript-namespaces


【解决方案1】:

在调用 fancybox 之前是否加载了 DOM?如果不试试这个:

$(document).ready(function() {
    $('a.fancy').fancybox({
        'transitionIn'  : 'none',
        'transitionOut' : 'none'
    });
});

【讨论】:

    【解决方案2】:

    我刚刚通过捆绑更新得到了这个。

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

    我使用了this,效果很好。

    jQuery 1.9 docs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-05
      • 2018-07-29
      • 2021-12-15
      • 2019-05-29
      • 2019-10-09
      • 2012-03-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多