<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Call custom modules within modules in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447498#M41329</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here: &lt;/SPAN&gt;&lt;A href="https://github.com/btfou/cutthroat-trout"&gt;https://github.com/btfou/cutthroat-trout&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When you can; no rush. Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 26 Oct 2013 00:39:36 GMT</pubDate>
    <dc:creator>BenFousek</dc:creator>
    <dc:date>2013-10-26T00:39:36Z</dc:date>
    <item>
      <title>Call custom modules within modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447491#M41322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have two modules in a folder called "mods", which is loaded as a package with dojoConfig.&amp;nbsp; I require ModuleA in ModuleB, and it loads.&amp;nbsp; But I can't use it as a variable of the define function, only by a legacy call (see code).&amp;nbsp; If I require ModuleA in the application I can use it normally.&amp;nbsp; Am I missing something?&amp;nbsp; Any help is appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ModuleA:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;define([&amp;nbsp; 'dojo/_base/declare' ], function (declare) { &amp;nbsp; return declare('mods.ModuleA', [], { &amp;nbsp;&amp;nbsp;&amp;nbsp; //create module &amp;nbsp; }); });&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ModuleB:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;define([&amp;nbsp; 'dojo/_base/declare',&amp;nbsp; 'mods/ModuleA' ], function (declare, ModuleA) { &amp;nbsp; return declare([], { &amp;nbsp;&amp;nbsp;&amp;nbsp; //create module &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; createA: function() { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(ModuleA); //returns an interger?!?! &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(mods.ModuleA); //returns module function() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.container.addChild(new ModuleA({a: 1, b: 'hi'})); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // throws an error because ModuleA = some integer &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.container.addChild(new mods.ModuleA({a: 1, b: 'hi'})); //legacy works?!?! &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }); });&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 22:56:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447491#M41322</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2013-10-21T22:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Call custom modules within modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447492#M41323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;im a little out of my depth here, but perhaps in your widgets you should be declaring a variable and 'return' it instead of returning your declare statement directly?&amp;nbsp; (ie like driskull does in his AMD home button widget).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/driskull/arcgis-dijit-home-button-js/blob/master/js/HomeButton.js"&gt;https://github.com/driskull/arcgis-dijit-home-button-js/blob/master/js/HomeButton.js&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Oct 2013 15:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447492#M41323</guid>
      <dc:creator>JohnGravois</dc:creator>
      <dc:date>2013-10-22T15:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Call custom modules within modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447493#M41324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks John. I did start declaring and returning a variable.&amp;nbsp; Still haven't worked it out.&amp;nbsp; In this case, I'm creating a custom layer and I think there's an issue with how I'm declaring it.&amp;nbsp; Not having that problem with other classes and widgets.&amp;nbsp; I'm sure the solution will come to me sooner or later.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Oct 2013 22:01:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447493#M41324</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2013-10-23T22:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Call custom modules within modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447494#M41325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;maybe worth it to try and deminify and dissect our &lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/en/javascript/jssamples/widget_directions_basic.html"&gt;directions&lt;/A&gt;&lt;SPAN&gt; widget and try to compare and contrast?&amp;nbsp; i'm fairly sure it relies on the geocoder widget.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Oct 2013 20:40:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447494#M41325</guid>
      <dc:creator>JohnGravois</dc:creator>
      <dc:date>2013-10-24T20:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Call custom modules within modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447495#M41326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Most likely, either the widget is not getting assigned to the correct variable or the module path is incorrect.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've updated my simple dijit sample to load a custom module from within another.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://github.com/driskull/arcgis-dijit-sample-js"&gt;https://github.com/driskull/arcgis-dijit-sample-js&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://driskull.github.io/arcgis-dijit-sample-js/"&gt;http://driskull.github.io/arcgis-dijit-sample-js/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is how I added the custom module:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://github.com/driskull/arcgis-dijit-sample-js/commit/23368142f9e8537fb919d0d9aeeae05c8ab785c7"&gt;https://github.com/driskull/arcgis-dijit-sample-js/commit/23368142f9e8537fb919d0d9aeeae05c8ab785c7&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Oct 2013 22:35:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447495#M41326</guid>
      <dc:creator>MattDriscoll</dc:creator>
      <dc:date>2013-10-24T22:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Call custom modules within modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447496#M41327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Still haven't figured it out. This is where I'm at:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Custom layer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;require(['dojo/_base/declare', 'esri/layers/layer', 'esri/layers/TileInfo', 'esri/geometry/Extent'], function (declare, layer, TileInfo, Extent) {
&amp;nbsp; var customLayer = declare('modules.CustomLayer', layer, {
&amp;nbsp;&amp;nbsp;&amp;nbsp; declaredClass: 'modules.CustomLayer',
&amp;nbsp;&amp;nbsp;&amp;nbsp; constructor: function (params) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; params = params || {};
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.tileInfo = new TileInfo( /*tile info*/ );
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.fullExtent = Extent( /*extent*/ );
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.initialExtent = Extent( /*extent*/ );
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.loaded = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onLoad(this);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; //functions blah blah blah
&amp;nbsp; });
&amp;nbsp; return customLayer;
});&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;require(['dojo/_base/declare', 'esri/map', 'modules/CustomLayer', 'dojo/domReady!'], function (declare, Map, CustomLayer) {
&amp;nbsp; var map = new Map('map-div', {
&amp;nbsp;&amp;nbsp;&amp;nbsp; //map params
&amp;nbsp; });

&amp;nbsp; console.log(CustomLayer); //returns integer 3
&amp;nbsp; console.log(modules.CustomLayer); //returns function()

&amp;nbsp; map.addLayer(new CustomLayer()); //fail

&amp;nbsp; map.addLayer(new modules.CustomLayer()); //works
});&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't understand why I need to set the className argument to even access the module, and I don't understand why I can't use the variable, but instead have to call the class itself. I'm not having to set className with templated widgets or other classes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:58:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447496#M41327</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2021-12-11T19:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Call custom modules within modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447497#M41328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you can post all your code I can take a look.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 20:54:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447497#M41328</guid>
      <dc:creator>MattDriscoll</dc:creator>
      <dc:date>2013-10-25T20:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Call custom modules within modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447498#M41329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here: &lt;/SPAN&gt;&lt;A href="https://github.com/btfou/cutthroat-trout"&gt;https://github.com/btfou/cutthroat-trout&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When you can; no rush. Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Oct 2013 00:39:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447498#M41329</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2013-10-26T00:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Call custom modules within modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447499#M41330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey Ben,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Looks like it's not working right because you're using require() instead of define() in the custom module. Change it to define() and it should work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Oct 2013 18:23:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447499#M41330</guid>
      <dc:creator>MattDriscoll</dc:creator>
      <dc:date>2013-10-26T18:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: Call custom modules within modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447500#M41331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Matt!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Oct 2013 19:16:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/call-custom-modules-within-modules/m-p/447500#M41331</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2013-10-26T19:16:52Z</dc:date>
    </item>
  </channel>
</rss>

