views:

40

answers:

1

I am getting used to the dojo toolkit. So my question is does the following code mean to load the base dojo code?

var djConfig = {  
     baseScriptUri: "js/dojo/"  
 };

Would I use the following code if I am using a CDN?

var djConfig = {    
     baseScriptUri: "http://o.aolcdn.com/dojo/"    
 };

or would I write the code this way?

var djConfig = {    
     baseScriptUri: "http://o.aolcdn.com/dojo/1.3.2/dojo/"    
 };

I am looking at a lot of dojo toolkit examples from the following website and they all have this code:

http://www.java2s.com/Tutorial/JavaScript/0570_Dojo-toolkit/Catalog0570_Dojo-toolkit.htm

+1  A: 

Loading Dojo

No. This code won't load any javascript file in your browser.

djConfig is the base configuration for the dojo framework (the way it loads resources, locales, parsing configuration...). Actually, the baseScriptUri key is not mandatory and tells dojo where to load additional resources (in case you changed the directory architecture).

So you still need that good old <script type="text/javascript" src="http://o.aolcdn.com/dojo/1.3.2/dojo/dojo.js" djConfig="YOUR CONFIG HERE"></script>.

For further questions, what version are you using?

Mode info on XDomain loading

If you want to load a XDomain version of dojo, you have to configure djConfig accordingly with useXDomain = true.

And don't forget to sprinkle dojo.addOnLoad() here and there when you expect your code to load other parts of dojo (that's the downside of XDomain loading).

Example:

<script type="text/javascript" src="http://o.aolcdn.com/dojo/1.3.2/dojo/dojo.xd.js" djConfig="useXDomain:true"></script>
Brian Clozel
I am using 1.3.2. so this does not have anything to do with djConfig.baseUrl?
Amen
Ok so dojo gives this example can you break it down to me? <script type="text/javascript"> djConfig = { isDebug: true, parseOnLoad: true, baseUrl: "./", modulePaths: { "coolio": "scripts/coolio" }, xdWaitSeconds: 10 }; </script> <script type="text/javascript" src="http://o.aolcdn.com/dojo/1.0.2/dojo/dojo.xd.js"></script> <script type="text/javascript"> dojo.require("dijit.ColorPalette"); dojo.require("coolio.actions"); </script> <script type="text/javascript"> dojo.addOnLoad(function(){ coolio.actions.foo(); }); </script>
Amen
You miss the "useXDomain = true" in you djConfig
Brian Clozel
And seriously, stop switching dojo version :-) dojo 1.1+ is the min you should do, especially for Xdomain loading purposes.
Brian Clozel
Ok thanks I understand.
Amen
I had to redo the <script> tag to make it work<script type="text/javascript" src="http://o.aolcdn.com/dojo/1.3.2/dojo/dojo.xd.js" djConfig="useXDomain:true">
Amen
sorry about the typo - I just edited my answer to make it right
Brian Clozel
no problem you answered the question.
Amen