Вопрос

http://dojotoolkit.org/reference-guide/loader/amd.html#generic-script-injection

When I'm using require() to do generic script injection, is there any way I can pass the injected script values without having to rely on globals?

Это было полезно?

Решение

Usually in Dojo land, when you require() in something, you are requiring a class, and then when you instantiate the class, you pass in constructor args.

You could use the addOnLoad callback to apply values as you want, if you just want access to generic Javascript:

dojo.require("my.awesome.code");
dojo.addOnLoad(function(){
   // Do something groundbreaking with my.awesome.code
});

Or in Dojo > 1.7 (AMD loader):

require(["dojo/ready", "my/awesome/code"], function(ready, code){
     // Do something groundbreaking with my.awesome.code
});

Take a look here for more info: dojo.require Overview

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top