Possible Duplicate:
Can I use multiple versions of jQuery on the same page?
I add some new javascript code in a website that is using 1.2.4. The code I add now need 1.8.2 version.
So, this is the code I have :
var thisPageUsingOtherJSLibrary = false;
if (typeof jQuery == 'undefined' || jQuery.fn.jquery !== '1.8.2') {
if (typeof $ == 'function') {
thisPageUsingOtherJSLibrary = true;
}
function getScript(url, success) {
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0];
done = false;
script.onload = script.onreadystatechange = function () {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
};
};
head.appendChild(script);
};
getScript('http://code.jquery.com/jquery-1.8.2.min.js', function () {
if (typeof jQuery !== 'undefined') {
if (!thisPageUsingOtherJSLibrary) {
jQuery(document).ready(function ($) {
initWithNewJquery($);
});
} else {
var jQuery_1_8_2 = $.noConflict(true);
jQuery_1_8_2(document).ready(function ($) {
initWithNewJquery($);
});
}
}
});
} else {
jQuery(document).ready(function ($) {
initWithNewJquery($);
});
}
function initWithNewJquery($){
}
what I need is : using the old jquery for the website where I add the code. Using the new jquery for my new functions/handler (that will be added inside function initWithNewJquery($)
).
For some reasons, I think the code I wrote is wrong, also because I get this error :
TypeError: a.livequery is not a function
So, how should I use correctly noConflict()
here?