Reputation: 9212
I am using a external Jquery plugin in my project. In plugin they are using jquery-1.3.2.js. For my functionality i am using library jquery/1.10.2/jquery.min.js.
The problem is that if i am commenting out jquery-1.3.2, some functionality of Plugin is not working. If i am having both the libraries Jquery on method is not working.
// This will not work if we have both the libraries.
$(document.body).on('click', '.productWrap', function(){
alert ("reaching here");
});
I don't have any idea what functionality of plugin is using jQuery-1.3.2.
How to fix this issue, so that plugin and on method both can work perfectly, without any major changes in the code.
Upvotes: 0
Views: 319
Reputation: 7597
Yes, it's possible; just use $.noConflict(true);
:
<!-- load jQuery 1.3.2 -->
<script type="text/javascript" src="http://example.com/jquery-1.3.2.js"></script>
<script type="text/javascript">
var jQuery_1_3_2 = $.noConflict(true);
</script>
<!-- load jQuery 1.10.2 -->
<script type="text/javascript" src="http://example.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
var jQuery_1_10_2 = $.noConflict(true);
</script>
Example:
Instead of
$('#selector').function();
you'd do
jQuery_1_3_2('#selector').function();
or
jQuery_1_10_2('#selector').function();
.
Upvotes: 2
Reputation: 4293
You can do this using jquery.noConflict - http://api.jquery.com/jQuery.noConflict/
Include your 1.3.2 version of jQuery.
Then include 1.10.2 version of jQuery.
Then do,
var j = jQuery.noConflict();
Hereafter, whereever you use $ in your script, you have to use j. Ex: $("#id1") => j("#id1")
Upvotes: 1