Reputation: 2721
I am using a widget on a page. The page is using jQuery 1.3.2 and many jQuery plugins on this page rely on jQuery 1.3.2. the widget is using jQuery 1.7.1, and many jQuery plugins serving for the widget rely on jQuery 1.7.1. The problem is when I use the sidjs library to load the widget to the page. There are conflicts that cause javascript errors because of jquery versions. I look up the internet and find out that I can use "$.noConflict()" to solve this. But I need to change codes at many places. I think I also need to change the code of the jQuery plugins. Is there any good methods to do this?
Upvotes: 2
Views: 429
Reputation: 25091
Add:
window.$jq171 = jQuery.noConflict();
to it's own .js file, and use SidJS to load it immediately afterwards if you are loading jQuery 1.7.1. The only way I can think of that would be easier than that is to add that same line at the very end of the jquery-1.7.1.js or the jquery-1.7.1.min.js file (whichever you're using). Personally, I'd keep it in it's own file.
Then in your scripts that reference jQuery 1.7.1, use $jq171
in place of the $
that you would normally type. Example follows:
$(document).ready(function () {
//normal style
});
becomes:
$jq171(document).ready(function () {
//normal style
});
Upvotes: 2