Login Register Help
API Documentation
Choose a stylesheet:

Constructordojo.require

defined in dojo/_base/_loader/loader.js

dojo.require("A.B") first checks to see if symbol A.B is defined. If it is, it is simply returned (nothing to do).

If it is not defined, it will look for A/B.js in the script root directory.

dojo.require throws an excpetion if it cannot find a file to load, or if the symbol A.B is not defined after loading.

It returns the object A.B.

dojo.require() does nothing about importing symbols into the current namespace. It is presumed that the caller will take care of that. For example, to import all symbols into a local block, you might write:

with (dojo.require("A.B")) {
    ...
}

And to import just the leaf symbol to a local variable:

var B = dojo.require("A.B");
...

Usage

var foo=new dojo.require(moduleName: String, omitModuleCheck: Boolean?);
parametertypedescription
moduleNameStringmodule name to load, using periods for separators, e.g. "dojo.date.locale". Module paths are de-referenced by dojo's internal mapping of locations to names and are disambiguated by longest prefix. See dojo.registerModulePath() for details on registering new modules.
omitModuleCheckBooleanOptional. if true, omitModuleCheck skips the step of ensuring that the loaded file actually defines the symbol it is referenced by. For example if it called as dojo.require("a.b.c") and the file located at a/b/c.js does not define an object a.b.c, and exception will be throws whereas no exception is raised when called as dojo.require("a.b.c", true)

PropertiesBack to top