Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had the same problem as you today. Here is how I could fix it :</p> <pre><code>requirejs.config({ "baseUrl": "js/lib", "paths": { "app": "../app" } }); // Final version of jQuery with all needed plugins. define("jquery", ["jquery-core", "myplugin"], function(jqCore) { return jqCore; }); // Define core jQuery module. define("jquery-core", ["jquery-1.9.1.min"], function() { return jQuery.noConflict(true); }); // This module exposes jquery module to the global scope and returns previous defined version. define("jq-global", ["jquery-core"], function(jqCore) { var tmp = jQuery; jQuery = jqCore; return tmp; }); // Define your plugin here, and don't forget to reset previous jQuery version. define("myplugin", ["jq-global", "jquery.myplugin"], function(jqGlobal, jqPlugin) { jQuery = jqGlobal; }); // Load the main app module to start the app requirejs(["app/main"]); </code></pre> <p>Now in my app/main.js file I can do the following :</p> <pre><code>define(["jquery"], function($) { $('body').myplugin(); }); </code></pre> <p>The idea here is to expose jQuery temporary before plugin code is executed. So far I didn't test the solution in a larger environment with a lot more modules to load, so I can't guarantee it will work in the long term ;)</p> <p><strong>Edit</strong></p> <p>This solution won't work!! Since requirejs doesn't load the scripts sequentially, it is possible the plugin js file loads before jquery which will cause the execution to fail. Sorry for this.</p> <p>If someone has another idea...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload