Using different versions of jQuery and jQueryUI together

前端 未结 3 1016
心在旅途
心在旅途 2020-12-02 15:53

I am working on a project where their framework uses jQuery 1.3.2 and jQueryUI 1.7.2.

Upgrading the versions in the framework is not a possibility so i wanted to run

3条回答
  •  一向
    一向 (楼主)
    2020-12-02 16:37

    I just figured a solution and it works for me.

    In the Jquery library, after the last line type

    var mySelector = $;
    

    Include the other version after you include this in your page.

    now, in all the scripts that you want to use with this jquery version(even jquery ui and other libraries too), replace $ with mySelector. Use replaceall, there will be a couple of places, like in regex match functions where you would want to replace mySelector back to $. This problem was bugging me for quite a long time. And it just got solved.

    EDITTED : be sure that you do not replace any $ inside the jQuery original script.

提交回复
热议问题