AnsweredAssumed Answered

Using ArcGIS JS API From Different Host Kills Access to Widgets on Page

Question asked by Zian on Aug 5, 2015

I would like to use a copy of the ArcGIS JavaScript API hosted on another server (say, ESRI's CDN) but I find that when I do that, I can no longer access any of the Dojo widgets on my page.

 

Has anyone found a workaround for the problem?

 

Sample code:

 

HTML File:

 

 

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="http://js.arcgis.com/3.14/dijit/themes/claro/claro.css">
    <link rel="stylesheet" type="text/css" href="http://js.arcgis.com/3.14/esri/css/esri.css">
    <script type="text/javascript" src="http://js.arcgis.com/3.14/"></script>
    <title>Map</title>
   
<script type="text/javascript" src="trivial.js"></script>

</head>

<body class="claro">  
   
    <div id="content"
        data-dojo-type="dijit/layout/LayoutContainer"
        data-dojo-id="content">
        <div id="right_pane"
            data-dojo-type="dijit/layout/ContentPane"
            data-dojo-props="region:'right'"
            data-dojo-id="right_pane">
        <div data-dojo-type="dijit/layout/StackContainer" data-dojo-id="sidebar_stack_container">Abc</div>
  </div>
       
    </div>
</body>
</html>

 

Contents of trivial.js

 

require([

  "dojo/parser",

  "dojo/domReady!"

], function (

  parser,

  domReady) {

   parser.parse();

var test = sidebar_stack_container;

});

 

Resulting F12 Developer Tools Error Message:

ReferenceError: 'sidebar_stack_container' is undefined in domReady callback ReferenceError: 'sidebar_stack_container' is undefined

   at Anonymous function (http://data.firstwatch.net/workspace/trivial.js:8:2)

   at ha (http://js.arcgis.com/3.14/:22:464)

   at Anonymous function (http://js.arcgis.com/3.14/:23:202)

   at ia (http://js.arcgis.com/3.14/:23:89)

   at fa (http://js.arcgis.com/3.14/:23:144)

   at b (http://js.arcgis.com/3.14/:24:122)

   at e (http://js.arcgis.com/3.14/:160:433)

   at d (http://js.arcgis.com/3.14/:161:360)

   {

      [functions]: ,

      __proto__: { },

      description: "'sidebar_stack_container' is undefined",

      message: "'sidebar_stack_container' is undefined",

      name: "ReferenceError",

      number: -2146823279,

      stack: "ReferenceError: 'sidebar_stack_container' is undefined

   at Anonymous function (http://data.firstwatch.net/workspace/trivial.js:8:2)

   at ha (http://js.arcgis.com/3.14/:22:464)

   at Anonymous function (http://js.arcgis.com/3.14/:23:202)

   at ia (http://js.arcgis.com/3.14/:23:89)

   at fa (http://js.arcgis.com/3.14/:23:144)

   at b (http://js.arcgis.com/3.14/:24:122)

   at e (http://js.arcgis.com/3.14/:160:433)

   at d (http://js.arcgis.com/3.14/:161:360)"

   }

   "in domReady callback"

   "ReferenceError: 'sidebar_stack_container' is undefined

   at Anonymous function (http://data.firstwatch.net/workspace/trivial.js:8:2)

   at ha (http://js.arcgis.com/3.14/:22:464)

   at Anonymous function (http://js.arcgis.com/3.14/:23:202)

   at ia (http://js.arcgis.com/3.14/:23:89)

   at fa (http://js.arcgis.com/3.14/:23:144)

   at b (http://js.arcgis.com/3.14/:24:122)

   at e (http://js.arcgis.com/3.14/:160:433)

   at d (http://js.arcgis.com/3.14/:161:360)"

Outcomes