Domanda

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?

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top