[Dojo-interest] XDomain dojo.require question

James Burke jburke at dojotoolkit.org
Fri Mar 5 16:43:05 EST 2010


On Fri, Mar 5, 2010 at 12:29 PM, Matthew Tyson
<matthewcarltyson at gmail.com> wrote:
> I've got my app set up for xdomain.  I have a few layer files that I've
> included using resourceName/modulePath.  They are successfully loaded.
>
> For some reason, dojo is still pulling down the individual files (like
> Toolbar.xd.js), even though they are in the layers.
>
> I have a theory about what to do, but I'd like to confirm this is correct:
>
> Leave my layer dojo.require()s where they are.  Move my individual module
> requires to an onLoad function.   Set parseOnLoad to false.  Call the
> individual require() function, then call dojo.parse (all in an onload
> function).

Maybe you could describe your setup some more. Here is a scenario I
know that works:

For a page, create a my/page1.js file, in there put all the
dojo.require calls you need for you page. Add
dojo.provide("my.page1"); at the top of it. In this example, "my" is
your own namespace for the code you create.

In the HTML page, load dojo.xd.js and then just have one
dojo.require("my.page1");

When doing an xdomain build, the build layer should be name:
"../my/page1.js" and its dependencies should just be "my.page1". The
build system will then create a build layer at the my/page1.xd.js
directory.

When you deploy your code, the dojo.require("my.page1") in the HTML
page should just load the page1.xd.js file.

James


More information about the Dojo-interest mailing list