admin管理员组文章数量:1289900
I'm stuck with an inpatible version of jQuery in my Angular app, I can't upgrade jQuery but can load the latest jQuery version side by side using the noConflict method but I cant seem to find a way to force Angular.js to use the newer jQuery version. Is there such a method available?
Flow:
<head>
<script src="jQuery 1.3.2">
<script src="old jquery code">
</head>
<body>
…
<script src="jQuery 1.10.2"/>
<script>
var newjquery = jQuery.noConflict();
</script>
<script src="angular.js"/>
<script>
// angular code
</script>
</body>
I'm stuck with an inpatible version of jQuery in my Angular app, I can't upgrade jQuery but can load the latest jQuery version side by side using the noConflict method but I cant seem to find a way to force Angular.js to use the newer jQuery version. Is there such a method available?
Flow:
<head>
<script src="jQuery 1.3.2">
<script src="old jquery code">
</head>
<body>
…
<script src="jQuery 1.10.2"/>
<script>
var newjquery = jQuery.noConflict();
</script>
<script src="angular.js"/>
<script>
// angular code
</script>
</body>
Share
Improve this question
edited Aug 21, 2013 at 12:52
Denim Datta
3,8024 gold badges28 silver badges53 bronze badges
asked Aug 21, 2013 at 12:25
Casper DeseyneCasper Deseyne
3311 gold badge3 silver badges11 bronze badges
4
- Could you post some code samples of how the individual script files of both angular and jQuery are included? – Alen Genzić Commented Aug 21, 2013 at 12:29
- 1 why cant you upgrade your jquery? or remove the old one? – David Chase Commented Aug 21, 2013 at 12:30
- I'm working on a big Drupal 6 project which es bundled with jQuery 1.3.2, upgrading breaks a lot of things. – Casper Deseyne Commented Aug 21, 2013 at 12:37
- As I updated my answer with the code example I got it working by placing the jQuery.noConflict after loading the newer version instead of placing it after the old version. Now everything seems to be working fine. The code in my question works. – Casper Deseyne Commented Aug 21, 2013 at 12:47
2 Answers
Reset to default 7From the docs:
Does Angular use the jQuery library?
Yes, Angular can use jQuery if it's present in your app when the application is being bootstrapped. If jQuery is not present in your script path, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.
Try to change the position in which you import the scripts:
- new jquery
- angular
- older jquery
I am not sure it would work, but from my understanding Angular should use the already present jQuery.
you can use the new directive ng-jq
with angular 1.4.x to set the Version of switch to jQLite (angular internal jQuery)
本文标签: javascriptHow to force angular to use jqlite or manually reference the jquery objectStack Overflow
版权声明:本文标题:javascript - How to force angular to use jqlite or manually reference the jquery object - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741464711a2380242.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论