开发者

Inclusion of more than two JQuery libraries creates problems

开发者 https://www.devze.com 2023-02-11 20:47 出处:网络
I am including these JQuery libraries: src=\"JQuery/jquery-1.4.2.min.js\" src=\"JQuery/jquery-ui-1.8.6.custom.min.js

I am including these JQuery libraries:

src="JQuery/jquery-1.4.2.min.js"
src="JQuery/jquery-ui-1.8.6.custom.min.js
src="JQuery/menu_login.js"
src="GjQuery/jquery-1.2.6.min.js"
src="GjQuery/jquery-ui-personalized-1.6rc2.min.js
src="GjQuery/jquery.flickr-1.0.js"
"GjQuery/jquery.flickrGallery-1.0.2.js"
<script type="text/javascript"> 
$().ready(function(){
$('#Gallery').flickrGallery({
    galleryHeight: 450
});
});
</script>

In this code, I am including 3 JQuery libraries in 开发者_开发技巧my Web application. I have two queries in my Web application before it's working fine, but when I have added the flickr library, it's doing problem. Problem is that as I include flickr library, the other two stop working. If I change the order of the inclusion then flickr library stops wroking or from other two one not doing work. Any idea?


What is the purpose behind including multiple versions of jQuery?

If you can, use only 1 (newest hopefully) version.

Alternatively, if each plugin you are using requires a different version, use NoConflict and make sure each plugin gets the correct version that it needs. You can also use closures and self invoking functions to still use $ like normal, while controlling which version you're using.

<script src="http://code.jquery.com/jquery-1.4.2.js"></script>
<!-- other scripts that depend on 1.4.2 --->
<script>
var $.1.4.2 = $.noConflict(true);
</script>

<script src="http://code.jquery.com/jquery-1.2.6.js"></script>
<!-- other scripts that depend on 1.2.6 --->
<script>
var $.1.2.6 = $.noConflict(true);
</script>

<script>
(function($){  
  // $ in here is jQuery 1.4.2 
})($.1.4.2);

(function($){
  // $ in here is jQuery 1.2.6 
})($.1.2.6);
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消