开发者

Conflicting jquery.min.js

开发者 https://www.devze.com 2023-03-14 05:59 出处:网络
I am using two different modules that both have jquery.min.js in my joomla site.They are confli开发者_StackOverflow中文版cting on my homepage.How can I distinguish between them for the homepage and fo

I am using two different modules that both have jquery.min.js in my joomla site. They are confli开发者_StackOverflow中文版cting on my homepage. How can I distinguish between them for the homepage and for the inside pages where the conflict does not occur?


I have faced this problem before, each module loads its own jQuery and conflicts each other.

The solution i have implemented is installing a plugin that prevents the modules from loading jQuery.js and loads only one. Try one of these, maybe it requires little tweaks to fully work:

Sc Jquery

jQuery Easy


$jQ = jQuery.noConflict();
$jQ("document").ready(function(){


// all the Code for Module X


});


(function($){

  // code here, you could even use $ here as you like

})(jQuery);


as sushil bharwani said: you should add <script type="text/javascript">jQuery = jQuery.noConflict();</script> into your header, right after you include jquery.min.js Also make sure you replace all '$' with 'jQuery' in your JS code.

0

精彩评论

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