Select to view content in your preferred language

Dojo conflict with datatables.js (Multipledefine) - ArcGIS API for JS 4.x

3674
1
Jump to solution
04-13-2019 11:26 PM
Muhammad_TayyabMir
Occasional Contributor

Hi

I have a Web GIS app using ArcGIS API for JS 4.11.

I want to use Datatables in it but I get the following errors on loading the datatables js files:

Error: multipleDefine
Error: scriptError: https://js.arcgis.com/4.11/dojo/jquery.js

Pretty much similar to this guy: https://community.esri.com/thread/217497-fixing-dojos-and-jquery-dependant-libraries-multipledefine-...

Do we have a workaround for this?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Muhammad_TayyabMir
Occasional Contributor

I solved it by using it in a separate Require() function instead of loading it at the top with dojo libraries.

require(["https://cdn.datatables.net/v/dt/jq-3.2.1/dt-1.10.16/datatables.js"], function () {
                        $(document).ready(function () {
                            var table = $('#customerTable').DataTable();
                        });
                      });

Surprisingly despite of this new require function itself being inside the main require function, where the dojo is loaded, this works somehow.

require(["esri/Map",
         "esri/views/MapView",
         "esri/layers/MapImageLayer",
         "esri/geometry/Point",
         "esri/geometry/projection",
         "esri/geometry/SpatialReference",
         "esri/symbols/SimpleMarkerSymbol",
         "esri/symbols/SimpleLineSymbol",
         "esri/Graphic",
         "esri/layers/GraphicsLayer",
         "dojo/domReady!"],
     function (Map,
         MapView,
         MapImageLayer,
         Point,
         projection,
         SpatialReference,
         SimpleMarkerSymbol,
         SimpleLineSymbol,
         Graphic,
         GraphicsLayer) { ... //New Require Function

View solution in original post

0 Kudos
1 Reply
Muhammad_TayyabMir
Occasional Contributor

I solved it by using it in a separate Require() function instead of loading it at the top with dojo libraries.

require(["https://cdn.datatables.net/v/dt/jq-3.2.1/dt-1.10.16/datatables.js"], function () {
                        $(document).ready(function () {
                            var table = $('#customerTable').DataTable();
                        });
                      });

Surprisingly despite of this new require function itself being inside the main require function, where the dojo is loaded, this works somehow.

require(["esri/Map",
         "esri/views/MapView",
         "esri/layers/MapImageLayer",
         "esri/geometry/Point",
         "esri/geometry/projection",
         "esri/geometry/SpatialReference",
         "esri/symbols/SimpleMarkerSymbol",
         "esri/symbols/SimpleLineSymbol",
         "esri/Graphic",
         "esri/layers/GraphicsLayer",
         "dojo/domReady!"],
     function (Map,
         MapView,
         MapImageLayer,
         Point,
         projection,
         SpatialReference,
         SimpleMarkerSymbol,
         SimpleLineSymbol,
         Graphic,
         GraphicsLayer) { ... //New Require Function
0 Kudos