<?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: Function not Firing From Button in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394448#M36411</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's not directly (officially) supported in Chrome or Firefox. You can read about some hackarounds &lt;A href="http://stackoverflow.com/questions/19761241/window-close-and-self-close-do-not-close-the-window-in-chrome"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Apr 2015 21:25:57 GMT</pubDate>
    <dc:creator>SteveCole</dc:creator>
    <dc:date>2015-04-07T21:25:57Z</dc:date>
    <item>
      <title>Function not Firing From Button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394444#M36407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good afternoon.&amp;nbsp; I have an application where I am tying a function to a button.&amp;nbsp; When the button is pressed, I want the window/application to close.&amp;nbsp; For some reason, I am getting the message that exitApplication is not defined.&amp;nbsp; Here is my simple code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JavaScript&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Exit Application if User does not Acknowledge&lt;/P&gt;&lt;P&gt;&amp;nbsp; function exitApplication() {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; window.close(); &lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTML Portion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;div dojotype="dijit.form.Button" id="buttonExit" data-dojo-type="dijit/form/Button" type="button" style="align-content: center" onclick="exitApplication();"&amp;gt;Close&amp;lt;/div&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have this working in another application (JavaScript 3.9 API).&amp;nbsp; I am now trying to get this to work using the JavaScript 3.13 API.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone have any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2015 18:46:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394444#M36407</guid>
      <dc:creator>IanPeebles</dc:creator>
      <dc:date>2015-04-07T18:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Function not Firing From Button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394445#M36408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think your best bet is to add an event listener for the click event of your button:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on(dom.byId('&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;buttonExit&lt;/SPAN&gt;'), 'click', 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; &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;exitApplication&lt;/SPAN&gt;();
&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;P&gt;&lt;/P&gt;&lt;P&gt;Since you're using a Dojo button, you could also do the same thing using dijit.byId as well:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on(dijit.byId('&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;buttonExit&lt;/SPAN&gt;'), 'click', 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; &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;exitApplication&lt;/SPAN&gt;();
&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>Sat, 11 Dec 2021 18:04:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394445#M36408</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2021-12-11T18:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: Function not Firing From Button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394446#M36409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is that function defined outside the "require" section of the code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;require([...], function(...){
&amp;nbsp; //more code
});

function exitApplication() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; window.close(); 
}&lt;/PRE&gt;&lt;P&gt;That's usually the issue when this error pops up. &lt;A href="https://community.esri.com/migrated-users/23538" target="_blank"&gt;Steve Cole&lt;/A&gt;​'s answer would probably have the same issue, since that would also be within the require. An alternative would be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;registry.byId('buttonExit').on('click', function() { 
&amp;nbsp;&amp;nbsp;&amp;nbsp; window.close();
});&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:04:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394446#M36409</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-11T18:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Function not Firing From Button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394447#M36410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This line of code is it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; registry.byId('buttonExit').on('click', function() {&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; window.close();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openedWindow.close();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for all of your responses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The window.close() works for I.E.&amp;nbsp; what works for closing Google Chrome and FireFox Browsers?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2015 21:02:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394447#M36410</guid>
      <dc:creator>IanPeebles</dc:creator>
      <dc:date>2015-04-07T21:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Function not Firing From Button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394448#M36411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's not directly (officially) supported in Chrome or Firefox. You can read about some hackarounds &lt;A href="http://stackoverflow.com/questions/19761241/window-close-and-self-close-do-not-close-the-window-in-chrome"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2015 21:25:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394448#M36411</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2015-04-07T21:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Function not Firing From Button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394449#M36412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My answer was partially incorrect. If the function is inside the require statement, like shown below, then the html code will not be able to access it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;require([...], function(...){&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //more code
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; function exitApplication() {&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; window.close();&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
});

&amp;lt;div dojotype="dijit.form.Button" id="buttonExit" data-dojo-type="dijit/form/Button" type="button" style="align-content: center" onclick="exitApplication();"&amp;gt;Close&amp;lt;/div&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When it is outside the require statement, like shown below, the event handling code won't be able to access it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;require([...], function(...){&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //more code
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; registry.byId('buttonExit').on('click', exitApplication);&amp;nbsp; 

});&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
function exitApplication() {&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; window.close();&amp;nbsp;&amp;nbsp; 
}&amp;nbsp; &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:04:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/function-not-firing-from-button/m-p/394449#M36412</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-11T18:04:18Z</dc:date>
    </item>
  </channel>
</rss>

