Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery force older version without changing jQuery selectors with no conflict

Tags:

jquery

I have a page that has jQuery 1.6.2. In some cases I load an app that requires jQuery 1.4.2. I need to force the app to use the 1.4.2 version. I am not able to change the selectors ($ to $$).

Is there a way to force the use of jQuery 1.4.2?

for instance onclick of an element I load the app. Right before I load the app can I use getScript to pull the old version of jQuery?

like image 788
jhanifen Avatar asked Aug 03 '11 15:08

jhanifen


1 Answers

Yes you can, check out this great article at http://blog.nemikor.com/2009/10/03/using-multiple-versions-of-jquery/.

Something like this:

<!-- load jQuery 1.6.2 -->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js"></script>

<!-- revert global jQuery and $ variables and store jQuery in a new variable -->
<script type="text/javascript">
var jQuery_1_6_2 = $.noConflict(true);

(function($){ 
   /* app code that uses jQuery 1.6.2 */ 
}(jQuery_1_6_2))

</script>


<!-- load jQuery 1.4.2 -->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>

<!-- revert global jQuery and $ variables and store jQuery in a new variable -->
<script type="text/javascript">
var jQuery_1_4_2 = $.noConflict(true);

(function($){ 
   /* app code that uses jQuery 1.4.2 */ 
}(jQuery_1_4_2))

</script>
like image 134
Mrchief Avatar answered Oct 06 '22 06:10

Mrchief