Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: defineAlreadyDefined

I get this error: Error: defineAlreadyDefined, that 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 loaded via ajax multiple times get Error: defineAlreadyDefined

EDIT: I searched and I think the way that i am trying to use requiJS and Dojo is wrong. http://dojotoolkit.org/features/1.6/async-modules

Any idea? thanks

like image 546
user947462 Avatar asked Apr 18 '12 17:04

user947462


1 Answers

In order to use a foreign loader w/ dojo you need to skip the dojo/dojo.js file, which defines the AMD loader. Your require config should have something like:

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

However, the dojo loader is just as good at loading jQuery plugins as requireJS and it comes with a few additional plugins, like dojo/has. I'd give serious thought to just using it's loader.

like image 74
fncomp Avatar answered Oct 02 '22 02:10

fncomp