问题描述:

I have specific task of having jquery and custom javascript inserted in DOM of existing page.

JQuery is inserted right before my script, and in mine script im using window['my$'] = jQuery.noConflict(true);.

This worked great when plugins were modified to bind on 'my$' version of jquery, without any conflict. Of course i had to modify plugins manually.

Problem came up when i had to bind jQuery mobile to my jQuery version. I tried 3 approaches and none of them worked correctly:

  1. wrapping up whole jquery mobile into function, and inside function $ and jQuery are declared as my$ variable:

    var jQuery = my$;

    var $ = my$

  2. i tried preserving original jQuery

    my$.holdReady(true);

    $_old = $;

    $ = my$;

    jQuery = my$;

    //code for adding jquery mobile

    jQuery = $_old;

    $ = $_old;

    my$.holdReady(false);

  3. Replacing all jQuery in jQuery mobile with my$

Any elegant solution for this problem?

相关阅读:
Top