dojo.require
<script src="../../js/dojo.js"></script>
defined in dojo/_base/_loader/loader.js
dojo._loadModule("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._loadModule
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._loadModule()
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._loadModule("A.B")) {
...
}
And to import just the leaf symbol to a local variable:
var B = dojo._loadModule("A.B");
...
parameter | type | description |
---|---|---|
moduleName | String | module name to load. 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. |
omitModuleCheck | Boolean | Optional. 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._loadModule("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._loadModule("a.b.c", true)` |