Select to view content in your preferred language

jQuery plugins conflicting with dojo

9738
3
09-24-2013 04:56 AM
JulienSilva
New Contributor
I'm currently implementing ArcGIS maps within a website that uses jQuery quite a lot.

Now some plugins like hammer.js call dojo's define function because of their UMD wrappers. This cause multipleDefine errors in my console. Is there a way to circumvent this? Do I have to set all these plugins as package in the dojoConfig object?

Here the code in hammer.js
    if(typeof define == 'function' && typeof define.amd == 'object' && define.amd) {

        // define as an anonymous module
        define(['jquery'], function($) {
          extendJquery(Hammer, $);
        });

    } else {
        extendJquery(window.Hammer, window.jQuery || window.Zepto);
    }


Thanks for your help.
0 Kudos
3 Replies
JonathanUihlein
Esri Regular Contributor
I *think* hammer.js uses the RequireJS module loader.

From:
http://requirejs.org/docs/dojo.html

As of Dojo 1.8, Dojo has converted their modules to AMD modules. However, Dojo uses some loader plugins, and the loader plugin APIs are still in draft mode for AMD. So while some modules from Dojo can be used with RequireJS, it will be difficult to use all of Dojo. It is best to use Dojo's AMD loader until ticket 15616 has been resolved.


I checked out ticket 15616 from the above quote and it seems there are some potential fixes or suggestions in the comments.

Hopefully this helps. I know it is doable with a little more searching. Good luck!
0 Kudos
JulienSilva
New Contributor
Hi Jon,

Sorry for my late reply. Thanks for your help. I will check out the ticket you've mentioned. I will post my solution here.
0 Kudos
ReneRubalcava
Honored Contributor
0 Kudos