Question

First of all, I'm using a custom build of dojo framework (v1.9.0) done with build.dojotoolkit.org/, with my required modules, included the loader module.

I have a question related to the dojo.require loader and the jQuery framework. The main question is about how can I to resolve the dependency between jQuery and jQueryUI (asn by extension with all the other plugins for jQuery).

I've been trying to do a simple test by loading them through this way:

require({
   async: true,
   baseUrl: 'js/GUIFramework/',
   tlmSiblingOfDojo: false,
   paths: {
      dojo: 'external/dojo/dojo-1.9',
      jQuery: 'external/jquery/jquery-1.9.1',
      jQueryUI: 'external/jquery/jquery-ui.min'
   }
},
[
   'jQuery',
   'jQueryUI'
],
    function (jQuery, jQueryUI) {
        var test = jQuery;
    });

But when the callback function is executed, after trying to load the modules, I have this error (see with firebug): "ReferenceError: jQuery is not defined" in jquery-ui.min.js (línea 5)

I've seen that other loaders, like RequireJS, have a configuration option called "shim" which specifically load files with non "define" function defined. But I haven't seen anything similar with the dojo.require.

Do you how to solve this for this specific case and for others similar that may occur?

Thank you, Regards.

Was it helpful?

Solution 2

After navigating a little more and looked for a "shim" implementation in Dojo, I have found a plugin, "use.js" (http://documentup.com/tbranyen/use.js) which seems to have the same functionality that a "shim" in RequireJS, and by the tests I've done until the moment, it seems to work fine.

I hope it to be helpful for anyone.

EDIT: The link I posted to use.js plugin is no longer available. Now you can see it here.

OTHER TIPS

A shim is actually nothing more than doing the following:

define([], function() {
    return jQuery;
});

jQuery and many other JavaScript libraries/frameworks add themself to the global scope, jQuery adds both the $ sign as jQuery. Now you just define your own jQuery shim module which returns that global variable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top