views:

34

answers:

2

I want to use a CDN version of Dojo but I also want to use my collection of widgets in my own name space. How do I make the two play together?

A: 

You need to config djConfig.modulePaths to point to your own modules. For exmaple:

modulePaths: {"com.yourdomain", "/js/com/yourdomain"}

virsir
I did something like this: <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.4.1/dojo/dojo.xd.js" type="text/javascript" djConfig="modulePaths: {'yoyo', '/js/yoyo'}"></script>and I get the error: "invalid object initializer"?
CpILL
You may need to put djConfig in the dojo script before<script>var djConfig = {modulePaths: {'yoyo', '/js/yoyo'}}</script><script src="ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.js>
virsir
Still gives me "invalid object initializer" :(
CpILL
A: 

You need to change djConfig.baseUrl too. The path of a module file is a combination of djConfig.baseUrl and module's path, if relative path is used in module path. See the example below.

<script type="text/javascript">
    var djConfig = {
        baseUrl : "./",
        modulePaths : {"example" : "js/example"}
    };
</script>    
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4.0/dojo/dojo.xd.js 
"></script>        
<script type="text/javascript">
    (function() {
        dojo.require("example.Sample");
        dojo.addOnLoad(function() {
            new example.Sample().sayHello();
        });
    })();
</script>

More details can be found at Cross-Domain Dojo.

Alex Cheng