As any software Jquery has evolved and has various releases available. You may have used Jquery plugins available for a feature required in your web application. There can be a scenario where you need to use plugins which are supported by different jquery versions. This tip explains how to go about using multiple versions of jquery.

Problem:
You have upgraded to Jquery 1.4.2 due to new features required for your Web application. However you have a plugin ABC that works in Jquery version 1.3.2. You need to get the ABC plugin working.

Solution:
You can continue using the ABC plugin by including both versions of Jquery in your Web Application. Follow the steps below:

Step 1. Load the Jquery 1.3.2 library
Step 2. Load all plugins that are supported only by Jquery 1.3.2
Step 3. Run the noConflict command for the included Jquery. $jq132 = jQuery.noConflict(true);
Step 4. Include the Jquery 1.4.2 library
Step 5. Include all plugins required and supported by Jquery 1.4.2
Step 5. Now you can used the old version of Jquery using $jq132 and new version using $

Below is code snippet:


<script type='text/javascript' src='js/jquery_1.3.2.js'></script>
<script type='text/javascript' src='js/ABC.js'></script>
<script type='text/javascript'>
   var $jq132 = jQuery.noConflict();
</script>
<script type='text/javascript' src='js/jquery_1.4.2.js'></script></code>

To invoke the old code for showing hiding a div with id “container”
$jq132(‘#container’).hide();

To invoke the new code for showing hiding a div with id “container”
$(‘#container’).hide();

Make sure you include the code only in the modules where you intend to use the plugin ABC. It may be just one page that requires the plugin.

That’s all guys we are now using two versions of Jquery in our Web application.

(Visited 1 times, 1 visits today)
Tags: ,
Category: Enterprise Linux, Technical Solutions
This entry was posted Monday, 18 October, 2010 at 11:00 am
You can follow any responses to this entry via RSS.

Leave a Reply

Your email address will not be published. Required fields are marked *

No comments yet