Search code examples
javascriptinclude-pathdojo

DOJO include files a directory back


I have dojo files in resources/js/dojo1.6/dojo/dojo.js

I have another file here resources/js/pages/file1.js

This file requires another file which is located at resources/js/folder/file2.js

This is how I am including it dojo.require('folder.file2');

So these three folder are in hirarchy

dojo1.6, pages and folder

When I run application

I got the following error

File not found: /resources/js/dojo1.6/folder/file2.js

How can I overcome this error.


Solution

  • You need to tell Dojo where your modules can be found, relative to dojo.js, using dojo.registerModulePath:

    dojo.registerModulePath("pages", "../../pages");
    dojo.registerModulePath("folder", "../../folder");
    

    See http://dojotoolkit.org/reference-guide/dojo/registerModulePath.html for a more detailed explanation.