When I use an import such as
<script type='text/javascript' src='http://o.aolcdn.com/dojo/1.2.3/dojo/dojo.xd.js' djConfig='parseOnLoad:true, isDebug: true'></script>
I get the error
dojox.data.CsvStore is not a constructor
for lines such as
var stateStore = new dojox.data.CsvStore({url: 'dojo-passcsv.php', label: 'name'});
but the error vanishes if I use an import from a local installation of dojo such as
<script type='text/javascript' src='dojo-release-1.2.3/dojo/dojo.js' djConfig='parseOnLoad:true, isDebug: true'></script>
I would really want to be able to use a CDN hosted dojo installation. Is there a known problem between the DojoX libraries and dojo.xd.js?
Thanks in advance,
Animesh
P.S. The dojo.require('dojox.data.CsvStore'); declarations are in place.
P.P.S The full ‘working code’ is below. Replacing the CSS and JS references with those from the CDN breaks it.
<html> <head> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'> <style type='text/css'> @import 'dojo-release-1.2.3/dijit/themes/tundra/tundra.css'; @import 'dojo-release-1.2.3/dojo/resources/dojo.css' </style> <script type='text/javascript' src='dojo-release-1.2.3/dojo/dojo.js' djConfig='parseOnLoad:true, isDebug: true'></script> <script> dojo.require('dojox.data.CsvStore'); dojo.require('dijit.Tree'); dojo.require('dojo.parser'); </script> <script type='text/javascript'> var stateStore = new dojox.data.CsvStore({url: 'states.csv', label: 'name'}); </script> </head> <body class='tundra'> <div dojoType='dijit.Tree' store='stateStore' labelAttr='name' label='States'> </div> </body> </html>
Reacting to your update:
I strongly think you should try with
dojo.addOnLoad(). Together, the last two<script>sections of your<head>would become:The problem with your original code is that you cannot guarantee that the constructor function
dojox.data.CsvStorehas been read by the time you are about to create yourstateStoreinstance of it. That’s wheredojo.addOnLoad()comes in, giving you a guarantee that the rest of the javascript was loaded prior to executing the abstract function passed as parameter ofaddOnLoad().Because it’s an issue of timing, your own original code may work sometimes, maybe not others: it would depend on the download speed and the order in which your browser pieces together the various javascript bits. That’s why using dojo’s remote library may occasionally give different results from using your own local copy of the dojo library.
That said, if you are using Firefox 3 (earlier than 3.0.6), then bear in mind what I said about the known bug. In that case, you may want to put that
<script>block immediately before the closing</body>tag… (That option would work on other browsers as well.)