I created a Dojo widget as shown below using the AMD bootloader in Dojo 1.7.2
var myCpane;
require([
"dijit/layout/ContentPane"
], function(ContentPane) {
myCpane = new ContentPane();
});
myCpane.startup();
In the above example, in the last status, the variable "myCpane" goes as "undefined", if I use "myCpane.startup ()" inside the require () callback function, then it will work fine.
But I want to use this variable "myCpane" outside the function "require" (for many reasons) . I know that the execution of the callback (require () "function is delayed due to the loading process of the Dojo component.
My question is:
- How to block the require () function until it completes the execution of this callback function.
, "myCpane" "undefined", "require()"
=============================================== ============
,
LoadModule: function(modulePath) {
var moduleObject = undefined;
require({async: false}, [modulePath], function(getModuleObject) {
moduleObject = getModuleObject;
});
while(moduleObject === undefined);
return moduleObject;
}
while, require(), "moduleObject".
require() ? , , "ContentPane.js" , . while, .
?