tags:

views:

588

answers:

2

I just started to learn Dojo. I followed one site Widget example with some different ways to load Dojo libraries. I like to use AOL reference to load dojo.js like this:

<script type="text/javascript" 
  src="http://o.aolcdn.com/dojo/1.2.0/dojo/dojo.xd.js"&gt;
</script>

and saved my widget codes in local web server like this:

scripts/
   myWidget/
     widgetExample.js
   ...
test.html

where widgetExample.js contains my widget class codes, and test.html is my testing page. The error message I got is: "uncaught exception: Could not load cross-domain resources: myWidget.widgetExample ...". I am not sure if I have to load dojo package locally? I really like to separate dojo library package as they are or loaded from AOL and only put my own codes in a local path. I tried to google about different domain loading, baseScriptUrl, and moduleMapping? Still not be able to figure out. Thanks for any detail instructions if any.

A: 
Eugene Lazutkin
+2  A: 

This may help: http://dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/xdomain-usage-dojo-loading-not-detecting-local-modules

The summary is: you need a djConfig item registering the modulePaths you want to be local, and specify a baseUrl to "trick" Dojo into thinking it knows where those paths are relative, across hosts.

djConfig = { modulePaths: { "mine":"/js/mine" };

then you can dojo.require("mine.Thing") from /js/mine/Thing.js

Regards, Peter Higgins