Error: defineAlreadyDefined

I get this error: Error: defineAlreadyDefined , which only occurs with dojo.

index.php

 <script data-main="app" src="require.js"></script> 

app.js

 require({ paths : { dojo : 'http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo' } }); require([ 'dojo' ], function() { //something }); 

I found a similar question but didn't help me:

When dojo.js loads through ajax several times get Error: defineAlreadyDefined

EDIT: I searched, and I think the way I'm trying to use requiJS and Dojo is incorrect. http://dojotoolkit.org/features/1.6/async-modules

Any idea? thanks

+7
source share
2 answers

To use the external w / dojo loader, you need to skip the dojo / dojo.js file, which the AMD loader defines. The require configuration should have something like:

 require({ packages: [ { name: 'dojo', location: 'dojo', main:'dojo/main' } ] }); 

However, the dojo loader is as good at loading jQuery plugins as requireJS, and it comes with several additional plugins like dojo/has . I would have thought just using its bootloader.

+3
source

I'm not sure what you want to do here, but Dojo implements requireJS . Therefore you do not need requireJS.

What are you doing for your normal use of the Dojo library:

 //call dojo script <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js"></script> <script> var dojoConfig = (function(){ return { async: true, //in case you wanted to use your own library paths: [{ name: "location/library"//your library path }] }; })(); require([ "dojo/parser", "name/something",//calling 'somethong' from library "dojo/domReady!" ], function(parser, something /*your library obj*/){ //your logic parser.parse(); something.do(); }); }); </script> 
0
source

All Articles