<?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: How to call module function on button click in arcgis javascript in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-call-module-function-on-button-click-in/m-p/370755#M34387</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You wont be able to call the module function unless your module is part of global variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one solution is you can change the context of the function by using lang.hitch like below&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;dom.byId("myButton").on("click", lang.hitch(myModule, function(){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.example();&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can pass "this" instead of myModule, if the event initialization and method are in the module.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 May 2015 13:26:40 GMT</pubDate>
    <dc:creator>thejuskambi</dc:creator>
    <dc:date>2015-05-19T13:26:40Z</dc:date>
    <item>
      <title>How to call module function on button click in arcgis javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-call-module-function-on-button-click-in/m-p/370753#M34385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to call module function on button click in arcgis javascript, example,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; dojo.connect(dom.byId("btnLocate"), "click", function ()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; example();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&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;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;function example()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("df");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myModule.queryStatesLayer();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;button style="height: 26px; width: 76px; margin-top: 22px;" name="btnLocate" onclick="example();"&amp;gt;Locate&amp;lt;/button&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here 'alert' is working but i can't access module function, how to call module function on button click? Please guide me with an example&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 13:07:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-call-module-function-on-button-click-in/m-p/370753#M34385</guid>
      <dc:creator>SadanandacharB1</dc:creator>
      <dc:date>2015-05-19T13:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to call module function on button click in arcgis javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-call-module-function-on-button-click-in/m-p/370754#M34386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am sure there is a better answer for this as whenever someone mentions "global vars", you should generally think "no" to avoid collisions and conflicts - however, I have accomplished this via the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;//instantiate your module
window.objmyModule = new myModule({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "myParam": paramValue
});

//call a module function after you've instantiated the object
objmyModule.myFunction();&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:10:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-call-module-function-on-button-click-in/m-p/370754#M34386</guid>
      <dc:creator>ChrisSmith7</dc:creator>
      <dc:date>2021-12-11T17:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to call module function on button click in arcgis javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-call-module-function-on-button-click-in/m-p/370755#M34387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You wont be able to call the module function unless your module is part of global variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one solution is you can change the context of the function by using lang.hitch like below&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;dom.byId("myButton").on("click", lang.hitch(myModule, function(){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.example();&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can pass "this" instead of myModule, if the event initialization and method are in the module.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 13:26:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-call-module-function-on-button-click-in/m-p/370755#M34387</guid>
      <dc:creator>thejuskambi</dc:creator>
      <dc:date>2015-05-19T13:26:40Z</dc:date>
    </item>
  </channel>
</rss>

