Ryan M
Ryan M

Reputation: 1761

Dojo cross domain load issue

I'm getting a cross domain error when trying to load a custom class. Here is my directory structure

lib

/dijit

/CustomClass1

gic

/dijit

/CustomClass2

CustomClass2 inherits from CustomClass1, but this is where I'm getting the cross domain error.

I'm including the require in CustomClass2:

require("lib.dijit.CustomClass1");

I believe I need to add a module path. I tried the statement below (with many variations) but I haven't gotten it to work. Any ideas?

dojo.registerModulePath("gic", "gic");

Upvotes: 0

Views: 547

Answers (1)

Craig Swing
Craig Swing

Reputation: 8162

Cross domain refers to retrieving the javascript files from a server that is not the domain that is serving the web application itself. An example is loading dojo from a CDN.

http://dojotoolkit.org/reference-guide/1.7/quickstart/cross-domain.html

From what you posted, I can't tell if you are using dojo from a CDN or not. If you are, then this link should help you configure your module path:

http://dojotoolkit.org/documentation/tutorials/1.6/cdn/

If not, then it is important to note that the second parameter is a directory path and is relative to dojo.js

dojo
  dojo.js
lib
  dijit
gic
  dijit

dojo.registerModulePath("lib", "../lib");
dojo.registerModulePath("gic", "../gic");

If you are having this problem doing a custom build, then you need to set prefixes in the profile:

prefixes: [
    [ "dijit", "../dijit" ],
    [ "lib", "../lib" ],
    [ "gic", "../gic" ]
]

Upvotes: 1

Related Questions