开发者

use two jquery version in one page [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

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

Hi,

in page i use jquery 1.4.4 version, but one of my script request older versio. I insert old jquery version and set new name:

<script type="text/javascript">var jq132 = $.noConflict(true);</script>

Then i get error on this line:

jq132("#docs_file ul").sortable({ opacity: 0.6, cursor: 'move', update: function()

Jus show(Firefox debuger): jq132("#docs_file ul").sortable is not a function

jq132(document).ready(function()
{   
    jq132(function()
    {
        jq132("#docs_file ul").sortable({ opacity: 0.6, cursor: 'move', update: function()
        {
            va开发者_StackOverflow社区r order = $(this).sortable("serialize") + '&action=Listings'; 
            jq132.post("order.php", order, function(theResponse){
                jq132("#error").html(theResponse);
            });                                                              
        }                                 
        });
    });

});


You need to call noConflict after including every plugin that you want to use.


sortable is a plug-in, which means it will try to add itself to jQuery by assigning to the jQuery.fn object. So if you want to use plug-ins with the older jQuery, you'll have to load them before you rename jQuery and before you load the newer version of it. E.g.:

<script src='jquery132.js'></script>
<script src='some.plugin.js'></script>
<script>var jq132 = jQuery.noConflict(true);</script>
<script src='jquery144.js'></script>
<script src='some.plugin.js'></script>

Note that lines 2 and 5 are the same. The first one will add that script to jQuery 132. The second will add it to jQuery 1.4.4. Maybe. If the script doesn't have its own global symbols. If it doesn't assume jQuery will continue to reference jQuery (which is a fairly reasonable assumption for it to make).

Live example

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜