Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a Cisco JS library designed to work using JQuery 1.4.2 and I'm using latest 2.X version of JQuery on the UI page I'm developing.

Cisco Library

I'm using Jabberwerx.js file from the above library link.

The library works fine if the JQuery loaded is of 1.4 but fails to work with later versions of JQuery. If I use old version of Jquery my UI based on bootstrap doesn't work. I tried to use noConflict() but then I can not edit the entire library which is very huge. There are lots of webservice calls and functions on the library so upgrading it is very painstaking.

Is it possible to use a particular version of JQuery on this JS file and the rest of the application can use the latest version of JQuery?

The library has this code on it. Can we change this to make it work using old version of JQ.

(function(window)
{   var jQuery=function(selector,context)
    {
        return new jQuery.fn.init(selector,context);
    },
    _jQuery=window.jQuery,
    _$=window.$,
}

I'm not looking at using different versions of JQuery on the same page but I'm trying to limit the usage of one version of JQuery to one of the JS files.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
192 views
Welcome To Ask or Share your Answers For Others

1 Answer

When you use different version of jquery then your code conflicts. So there may appear obvious errors.

To fix it, you need to use $.noConflict() passing a boolean parameter true.

jQuery.noConflict(true);
//removes jquery itself and allows you to work with different version of jquery

Example:

<script src="jquery-version-1.0"></script>
<script>//code for v-1</script>
<script>jQuery.noConflict(true);//remove jquery</script>
<script src="jquery-version-2.0"></script><!--use another version-->
<script>//code for v-2</script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...