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
2010-03-11 03:01:06
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
2010-03-11 05:26:32
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
2010-03-11 07:12:33
Still gives me "invalid object initializer" :(
CpILL
2010-03-11 10:38:55
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
2010-03-12 02:38:38