哪个图书馆覆盖$? [英] which library is overriding the $?

查看:132
本文介绍了哪个图书馆覆盖$?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jquery / bootstrap / and requirejs



加载js文件工作正常,我检查引导程序设置$ .fn.tab = someFunction; / p>

但是,在requirejs的回调函数中,调用$(foo).tab('show')会导致一个错误,表示该选项卡不可用于该对象。



未捕获TypeError:Object [object Object]没有方法'tab'



一切正常,我确认他们通过打印一个日志。

但我猜,$被重新定义或某事。

我应该从哪里开始看?

grep'$ \s * ='



我的代码相当长我发布了一个不同的问题: jquery,bootstrap 3.0 ,和requirejs。不能使用bootstrap的功能



我使用django,如果这有任何区别

解决方案

在尝试使用引导程序时,引导程序未能完成加载。尝试将requirejs配置中的bootstrap垫片更改为:

  shim:{
bootstrap:{
deps:[jquery],
export:$ .fn.tab
}
}

RequireJS将等待执行任何代码,取决于引导,直到$ .fn.tab设置为止。


I'm trying to use jquery/bootstrap/ and requirejs

Loading js files works perfectly and I checked that bootstrap sets $.fn.tab = someFunction;

but then, inside requirejs's callback function, calling $(foo).tab('show') results in an error saying that tab is not available for the object.

Uncaught TypeError: Object [object Object] has no method 'tab'

Everything loads fine, I confirmed they do by printing a log.
But I guess $ is redefined or something.
Where should I start to look?
grep '$\s*=' ?

my code is rather long and I posted under a different question: jquery, bootstrap 3.0, and requirejs. can't use bootstrap's functions

I'm using django if that makes any difference

解决方案

The problem is likely that bootstrap hasn't finished loading at the time you try to use it. Try changing your bootstrap shim in the requirejs config to this:

shim: {
  "bootstrap": {
    deps: ["jquery"],
    exports: "$.fn.tab"
  }
}

RequireJS will wait to execute any code depending on bootstrap until $.fn.tab is set.

这篇关于哪个图书馆覆盖$?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆