Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is the Simplified CommonJS Wrapper syntax not working on my Dojo AMD module?
    text
    copied!<p>Im starting to sort of wrap my head around requirejs and the new Dojo AMD structure, but I have a problem with some early tests:</p> <p>cg/signup.js:</p> <pre><code>define(['dojo/_base/fx', 'dojo/dom'], function(fx, dom){ return function(){ this.hidePreloader = function(id){ var preloader = dom.byId(id); fx.fadeOut({node : preloader}).play() } } }) </code></pre> <p>This works fine. In the master cg.js file:</p> <pre><code>require(['dojo/_base/kernel', 'dojo/_base/loader']) dojo.registerModulePath('cg', '../cg') require(['cg/signup', 'dojo/domReady!'], function(Signup){ var sp = new Signup(); sp.hidePreloader('preloader') }) </code></pre> <p>Bam. Done. However, in using the Simplified CommonJS Wrapper structure:</p> <pre><code>define(function(require){ var fx = require('dojo/_base/fx'), dom = require('dojo/dom'); return function(){ this.hidePreloader = function(id){ var preloader = dom.byId(id); fx.fadeOut({node : preloader}).play() } } }) </code></pre> <p>I get an undefinedModule error. It seems to come from the <code>dojo/_base/fx</code> line, but I don't know why.</p> <p><strong>UPDATE</strong></p> <p>For clarification.</p> <p><em>index.html scripts</em></p> <pre><code>&lt;script type="text/javascript" src="js/dojo/dojo.js.uncompressed.js" data-dojo-config="isDebug:true,async:true"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/cg.js"&gt;&lt;/script&gt; </code></pre> <p><em>cg.js</em></p> <pre><code>require(['dojo/_base/kernel', 'dojo/_base/loader']) dojo.registerModulePath('cg', '../cg') require(['cg/signup', 'dojo/domReady!'], function(signup){ signup.testFunc() }) </code></pre> <p><em>js/cg/signup.js</em></p> <pre><code>define(['require', 'exports'], function(require, exports){ var dom = require('dojo/_base/kernel'); // Any other require() declarations (with very very few exceptions like 'dojo/_base/array throw undefinedModule errors!!! // without any error causing requires, this works fine. exports.testFunc = function(){ alert("hello") } }) </code></pre>
 

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