<?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: Same code to be triggered by more than one event in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35241#M2916</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the quick response! I added:&lt;/P&gt;&lt;P&gt;"dojo/_base/lang" and lang in the require/function sections, tested and the page was able to load. It was not able to load when I only added "lang" and lang. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then added the event and function code and got the message "Type error: test is not a function" in the console. Any idea as to what I am doing wrong? Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Dec 2015 23:15:41 GMT</pubDate>
    <dc:creator>StefanCoe</dc:creator>
    <dc:date>2015-12-21T23:15:41Z</dc:date>
    <item>
      <title>Same code to be triggered by more than one event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35239#M2914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have two events and I want them both to trigger the same code. The obvious answer is to have each event call the same function but i cant figure out how to do this. For example, say i am using the esri search dijit s:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; on(s, "search-results", function(evt) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('event fired');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; test(evt);&lt;/P&gt;&lt;P&gt;&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;I have confirmed that the event gets fired but the function test is not found. Is this a scope issue? Any ideas? Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Dec 2015 22:32:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35239#M2914</guid>
      <dc:creator>StefanCoe</dc:creator>
      <dc:date>2015-12-21T22:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Same code to be triggered by more than one event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35240#M2915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Yes it is a scope issue. Here is how to handle it.&lt;/P&gt;&lt;P&gt;Add a require for lang and then this code.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;on(s, "search-results", lang.hitch(this, function(evt) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('event fired');
&amp;nbsp;&amp;nbsp;&amp;nbsp; test(evt);
}));&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:22:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35240#M2915</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-10T21:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Same code to be triggered by more than one event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35241#M2916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the quick response! I added:&lt;/P&gt;&lt;P&gt;"dojo/_base/lang" and lang in the require/function sections, tested and the page was able to load. It was not able to load when I only added "lang" and lang. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then added the event and function code and got the message "Type error: test is not a function" in the console. Any idea as to what I am doing wrong? Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Dec 2015 23:15:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35241#M2916</guid>
      <dc:creator>StefanCoe</dc:creator>
      <dc:date>2015-12-21T23:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Same code to be triggered by more than one event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35242#M2917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I would have to see more of your code as using lang.hitch should work for putting the results functions scope where it would know that test is a function unless you have the test function inside a different code block or another functions scope.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Dec 2015 23:43:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35242#M2917</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-12-21T23:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Same code to be triggered by more than one event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35243#M2918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert, the code is attached- sorry it's pretty messy right now. I was able to incorporate an event and function to one of ESRI's select samples and your suggestion worked so there is something definitely wrong with my code. The event fires when you choose an item from the select tool. If you type 'sound' in the search box several results will appear so just pick one of those. I really appreciate your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Dec 2015 01:08:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35243#M2918</guid>
      <dc:creator>StefanCoe</dc:creator>
      <dc:date>2015-12-22T01:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Same code to be triggered by more than one event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35244#M2919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; The issue seems to be with the use of the name "test" for the function name. Once I changed it to test2 it worked. I removed a bunch of legacy style coding you had mixed in with your AMD style also.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Dec 2015 01:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35244#M2919</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-12-22T01:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Same code to be triggered by more than one event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35245#M2920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much Robert! I really appreciate it! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Dec 2015 03:08:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/same-code-to-be-triggered-by-more-than-one-event/m-p/35245#M2920</guid>
      <dc:creator>StefanCoe</dc:creator>
      <dc:date>2015-12-22T03:08:41Z</dc:date>
    </item>
  </channel>
</rss>

