Skip to content Skip to sidebar Skip to footer

Requirejs Module Is Undefined

I have following directory structure scripts modules tabs.js app.js I have following code in app.js define([ 'jquery', 'underscore', 'modules/tabs',

Solution 1:

If you define a circular dependency ("a" needs "b" and "b" needs "a"), then in this case when "b"'s module function is called, it will get an undefined value for "a". "b" can fetch "a" later after modules have been defined by using the require() method (be sure to specify require as a dependency so the right context is used to look up "a"):

//Inside b.js:define(["require", "a"],
    function(require, a) {
        //"a" in this case will be null if "a" also asked for "b",//a circular dependency.returnfunction(title) {
            returnrequire("a").doSomething();
        }
    }
);

http://requirejs.org/docs/api.html#circular

Post a Comment for "Requirejs Module Is Undefined"