• Resolved dhunink

    (@dhunink)


    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 proces. I know the scope of this question is rather broad, but any thoughts at all are very much appreciated.

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

    -Things stopt 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&gt;

    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.

    Any thoughts, suggestions of comments are highly appreciated! Feel free to see all in action at https://tpgrf.nl/testserver/alpha/topotrainer/provincies/.

    Error screenshot: http://i.stack.imgur.com/za1ge.png
    False loading screenshot: http://i.stack.imgur.com/3Vqyr.png

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Marius L. J.

    (@clorith)

    Hi,

    Did you get this issue resolved? I had a look at your site and it loads fine without any site breaking errors.

    Thread Starter dhunink

    (@dhunink)

    Hi Marius!

    I didn’t’ resolved it but did narrowed it down to a jQuery UI issue (and more specific, I guess it’s in the require statement dat both jQuery UI and DoJo want to use AMD style).
    The error doesn’t appear when I deregister the following three scripts:

    wp_deregister_script('jquery-ui-core');
    wp_deregister_script('jquery-ui-progressbar');
    wp_deregister_script('jquery-effects-slide');

    For testing purposes I have commented out the first line; you would see the error occur if you visit https://tpgrf.nl/testserver/alpha/topotrainer/provincies/ right now.

    Thread Starter dhunink

    (@dhunink)

    Finally fixed it, although I’m still wondering why this was needed to be fixed with WP 4.1, wile it worked without this fix in WP 4.0

    Turned out that the problem was in timing. WordPress is loading jQuery UI in the footer (which is excellent, off course). Loading any JS file that uses the DoJo loader BEFORE the jQuery UI script tags, breaks it.

    So I ended up with a solution that forces any DoJo related JS file in the footer:

    wp_register_script('arcgis-api-js', $serverProtocol.'//js.arcgis.com/3.12/', array('jquery'), NULL, true);
    wp_register_script('page_provincies_map-js', $scriptdir.'/js/tpgrf_page_provincies_map.js', array('arcgis-api-js'), NULL, true);
    
    wp_enqueue_script('arcgis-api-js');
    wp_enqueue_script('page_provincies_map-js');

    Moderator Marius L. J.

    (@clorith)

    You could also set jquery-ui as a dependency for your scripts to ensure they’re loaded in the right order 🙂

    Thread Starter dhunink

    (@dhunink)

    I tried this way:

    wp_register_script('arcgis-api-js', '//js.arcgis.com/3.12/', array('jquery', 'jquery-ui-core'), NULL, false);

    Unfortunately without succes

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WordPress 4.1 upgrade broke DoJo integration’ is closed to new replies.