0

i got plugins using 3 different versions of jQuery on my site "1.7.1" "1.5.2" and "1.3.2". Got first 2 on my main page and theyre working just fine, but when i enter a site that uses the third one aswell, addons based on 1.7.1 and 1.5.2 stop working.

I did try adding jq132 = jQuery.noConflict(true); script, and then switching every $ in third app to jq132, but that doesnt seem to work. Any tips?

EDIT: i managed to cut out 1.5.2 and 1.3.2 versions, thanks for tips

mmln
  • 2,104
  • 3
  • 24
  • 33
  • 4
    Here's a tip: Use one version of jquery. – Gabe Feb 07 '12 at 02:08
  • Just curious: Why do you have 3 different versions of jQuery on the same page? – Ates Goral Feb 07 '12 at 02:08
  • because i got 3 js apps that use different versions if jQuery, how could i use just one version in this case? – mmln Feb 07 '12 at 02:10
  • @Ates Goral, yea true, I guess when I go to the gas station and fill up I use a little from 87, a little from 89 and top it off with some 92. – Gabe Feb 07 '12 at 02:10
  • 1
    USe the latest version. Its backward compatible. Better still upgrade your js plugins. Here, we crib about including as little code as possible to speed things up and you're using 3 different versions of jquery. The footprint will be enormous – SoWhat Feb 07 '12 at 02:13
  • Duplicate: http://stackoverflow.com/questions/1566595/can-i-use-multiple-versions-of-jquery-on-the-same-page – CodeJoust Feb 07 '12 at 02:16

2 Answers2

1

What you're probably doing wrong is not calling $.noConflict right after including a version of jQuery. After every jQuery include tag, there needs to be <script> tag with $.noConflict for that version of jQuery.

See: Can I use multiple versions of jQuery on the same page?

Community
  • 1
  • 1
CodeJoust
  • 3,760
  • 21
  • 23
1

You could try editing each version of jQuery to change the namespace variable for each version if you really need all three versions (which you really don't, btw).

(function( window, undefined ) {

// Use the correct document accordingly with window argument (sandbox)
var document = window.document,
    navigator = window.navigator,
    location = window.location;

var jQuery132 = (function() {

// Define a local copy of jQuery
var jQuery = function( selector, context ) {

and then in your $(document).ready():

jQuery132(document).ready(function($132) {
   // code goes here
});

and your $ would be replaced with $132 for your 1.3.2 version and so on.

Btw, this is a really bad idea.

daniel0mullins
  • 1,937
  • 5
  • 21
  • 45