[GIS] ArcGIS Javascript API on WordPress 4.1

arcgis-javascript-apidojojquery

SOLUTION: For everyone interested: turned out the solution was moving all files that use DoJo beneath the jQuery UI files, so that jQuery UI is fully loaded before any DoJo stuff loads. Moved them all in the footer in that order (jQuery, then jQuery UI and then alle DoJo related files).

Edit: to keep things organized:

I'm running a WordPress website which uses both jQuery and DoJo (part of the ArcGIS JS API, loaded from http://js.arcgis.com/3/12/).
After recently upgrading from WordPress 4.0.1 to 4.1, things broke.
Dojo is returning multiple Error: multipleDefine errors.

Basically it looks like DoJo tries to load a new instance of jQuery, which it shouldn't, since WordPress has loaded jQuery already and there isn't a jQuery module available in the DoJo map. Furthermore, this issues seems to only exists in WordPress, not in a jsfiddle I made including exactly the same scripts.

For debugging purposes I first disabled all WordPress plugins, without any result; the problem kept existing. I went on and found a couple of interesting things. But I'm really stuck in the further debugging proccess. I know the scope of this question is rather broad.

What I know so far/that i'm wondering about:

-Things stopped working after upgrading to WordPress 4.1

-In the info of the multipleDefine error it states https://js.arcgis.com/3.11/jquery.js, which is weird: it shouldn't be looking for jQuery there, since it's already included in WordPress

-Things break as soon as I included the ArcGIS Javascript API, which includes DoJO, but only in WordPress; on a jsfiddle things work fine http://jsfiddle.net/dhunink/mry5vn3s/7/

<script>
  var dojoConfig = { 
    isDebug: true,
    async: false
  };
</script>

<script src="http://js.arcgis.com/3.12/"></script>

enter image description hereenter image description here
The things mentioned above leads me to the conclusion that something changed in the last WordPress release that effects my script, although I can't find anything in the release notes that could be linked to my issue.

Feel free to see all in action at https://tpgrf.nl/testserver/alpha/topotrainer/provincies/.

Best Answer

I removed the Jquery UI scripts at the end of the page in https://tpgrf.nl/testserver/alpha/topotrainer/provincies/.

All those scripts start with the base URL https://tpgrf.nl/testserver/alpha/wp-includes/js/jquery/ui.

Moving them up just before the variable translObj fixed it.

JQuery UI is trying to define the global function define when it already exists, creating a conflict.

Related Question