<?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: Firing a event or dispatching a event in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/firing-a-event-or-dispatching-a-event/m-p/159244#M14860</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;JavaScript and Actionscript are quite similar in regards of syntax, especially if you ever did some AS2 development.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can have an element dispatch an event similar to AS3&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://developer.mozilla.org/en-US/docs/DOM/EventTarget.dispatchEvent" rel="nofollow noopener noreferrer" target="_blank"&gt;https://developer.mozilla.org/en-US/docs/DOM/EventTarget.dispatchEvent&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Doing the same on regular JS objects (non-dom elements) takes some elbow grease, but Dojo in the JS API provides some very nice utilities to accomplish this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://livedocs.dojotoolkit.org/dojo/Evented" rel="nofollow noopener noreferrer" target="_blank"&gt;http://livedocs.dojotoolkit.org/dojo/Evented&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you extend a new class based on dojo/Evented, you get access to some nice event delegation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Dojo docs seem to be acting up, but an example would be something like&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var MySumClass = declare(['dojo/Evented'], {
&amp;nbsp; constructor: function(x, y) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.x = x;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.y = y;
&amp;nbsp; }
&amp;nbsp; dispatch: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.emit('myEvent', {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message: 'This is a test message.',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result: this.x + this.y
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp; }
});

var myInstance = new MySumClass(5,10);
myInstance.on('myEvent', function(results) {
&amp;nbsp; console.log('message', results.message);
&amp;nbsp; console.log('results', results.result);
});
myInstance.dispatch(); // console logs print at this point
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This also gives you the ability to to use dojo/on with dojo/Evented&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://livedocs.dojotoolkit.org/dojo/on" rel="nofollow noopener noreferrer" target="_blank"&gt;http://livedocs.dojotoolkit.org/dojo/on&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This opens up some cool uses where you can listen for events only once, pause them, remove them and so on.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 08:24:35 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2021-12-11T08:24:35Z</dc:date>
    <item>
      <title>Firing a event or dispatching a event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/firing-a-event-or-dispatching-a-event/m-p/159243#M14859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can some body suggest or guide on how to dispatch a event from a java script method some thing like dispatchEvent() in the Adobe Flex framework.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is that possible from the ESRI Java script API or not?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One more thing can we create a custom layer which displays some html content on the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I mean I need to create layer to display a html page on the map.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Apr 2013 10:54:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/firing-a-event-or-dispatching-a-event/m-p/159243#M14859</guid>
      <dc:creator>ShashankA</dc:creator>
      <dc:date>2013-04-23T10:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Firing a event or dispatching a event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/firing-a-event-or-dispatching-a-event/m-p/159244#M14860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;JavaScript and Actionscript are quite similar in regards of syntax, especially if you ever did some AS2 development.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can have an element dispatch an event similar to AS3&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://developer.mozilla.org/en-US/docs/DOM/EventTarget.dispatchEvent" rel="nofollow noopener noreferrer" target="_blank"&gt;https://developer.mozilla.org/en-US/docs/DOM/EventTarget.dispatchEvent&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Doing the same on regular JS objects (non-dom elements) takes some elbow grease, but Dojo in the JS API provides some very nice utilities to accomplish this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://livedocs.dojotoolkit.org/dojo/Evented" rel="nofollow noopener noreferrer" target="_blank"&gt;http://livedocs.dojotoolkit.org/dojo/Evented&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you extend a new class based on dojo/Evented, you get access to some nice event delegation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Dojo docs seem to be acting up, but an example would be something like&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var MySumClass = declare(['dojo/Evented'], {
&amp;nbsp; constructor: function(x, y) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.x = x;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.y = y;
&amp;nbsp; }
&amp;nbsp; dispatch: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.emit('myEvent', {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message: 'This is a test message.',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result: this.x + this.y
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp; }
});

var myInstance = new MySumClass(5,10);
myInstance.on('myEvent', function(results) {
&amp;nbsp; console.log('message', results.message);
&amp;nbsp; console.log('results', results.result);
});
myInstance.dispatch(); // console logs print at this point
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This also gives you the ability to to use dojo/on with dojo/Evented&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://livedocs.dojotoolkit.org/dojo/on" rel="nofollow noopener noreferrer" target="_blank"&gt;http://livedocs.dojotoolkit.org/dojo/on&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This opens up some cool uses where you can listen for events only once, pause them, remove them and so on.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:24:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/firing-a-event-or-dispatching-a-event/m-p/159244#M14860</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-11T08:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Firing a event or dispatching a event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/firing-a-event-or-dispatching-a-event/m-p/159245#M14861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;JavaScript and Actionscript are quite similar in regards of syntax, especially if you ever did some AS2 development.&lt;BR /&gt;You can have an element dispatch an event similar to AS3&lt;BR /&gt;&lt;A href="https://developer.mozilla.org/en-US/docs/DOM/EventTarget.dispatchEvent" rel="nofollow noopener noreferrer" target="_blank"&gt;https://developer.mozilla.org/en-US/docs/DOM/EventTarget.dispatchEvent&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Doing the same on regular JS objects (non-dom elements) takes some elbow grease, but Dojo in the JS API provides some very nice utilities to accomplish this.&lt;BR /&gt;&lt;A href="http://livedocs.dojotoolkit.org/dojo/Evented" rel="nofollow noopener noreferrer" target="_blank"&gt;http://livedocs.dojotoolkit.org/dojo/Evented&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If you extend a new class based on dojo/Evented, you get access to some nice event delegation.&lt;BR /&gt;&lt;BR /&gt;The Dojo docs seem to be acting up, but an example would be something like&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var MySumClass = declare(['dojo/Evented'], {
&amp;nbsp; constructor: function(x, y) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.x = x;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.y = y;
&amp;nbsp; }
&amp;nbsp; dispatch: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.emit('myEvent', {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message: 'This is a test message.',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result: this.x + this.y
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp; }
});

var myInstance = new MySumClass(5,10);
myInstance.on('myEvent', function(results) {
&amp;nbsp; console.log('message', results.message);
&amp;nbsp; console.log('results', results.result);
});
myInstance.dispatch(); // console logs print at this point
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;This also gives you the ability to to use dojo/on with dojo/Evented&lt;BR /&gt;&lt;A href="http://livedocs.dojotoolkit.org/dojo/on" rel="nofollow noopener noreferrer" target="_blank"&gt;http://livedocs.dojotoolkit.org/dojo/on&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This opens up some cool uses where you can listen for events only once, pause them, remove them and so on.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&amp;nbsp; odoe for giving a quick reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By following above approach you suggested we are creating a event on the HTML element not on the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to dispatch a zoom event on the map from a java script function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By following the above approach,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If we add the event handler to the map using dojo.connect(map,"onClcik",handleClickEvent);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "handleClickEvent" handler will not be invoked when we dispatch the event from the simulateClick(). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; we need to add the functionality what we want to do in the else part of the if condition.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the whole I want to dispatch a "onZoom" event on the map from a java script function and the ESRI api should handle the zoom event as it does normally or by default(zoom's the map at a particular location).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:24:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/firing-a-event-or-dispatching-a-event/m-p/159245#M14861</guid>
      <dc:creator>ShashankA</dc:creator>
      <dc:date>2021-12-11T08:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Firing a event or dispatching a event</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/firing-a-event-or-dispatching-a-event/m-p/159246#M14862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;JavaScript and Actionscript are quite similar in regards of syntax, especially if you ever did some AS2 development.&lt;BR /&gt;You can have an element dispatch an event similar to AS3&lt;BR /&gt;&lt;A href="https://developer.mozilla.org/en-US/docs/DOM/EventTarget.dispatchEvent" rel="nofollow noopener noreferrer" target="_blank"&gt;https://developer.mozilla.org/en-US/docs/DOM/EventTarget.dispatchEvent&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Doing the same on regular JS objects (non-dom elements) takes some elbow grease, but Dojo in the JS API provides some very nice utilities to accomplish this.&lt;BR /&gt;&lt;A href="http://livedocs.dojotoolkit.org/dojo/Evented" rel="nofollow noopener noreferrer" target="_blank"&gt;http://livedocs.dojotoolkit.org/dojo/Evented&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If you extend a new class based on dojo/Evented, you get access to some nice event delegation.&lt;BR /&gt;&lt;BR /&gt;The Dojo docs seem to be acting up, but an example would be something like&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var MySumClass = declare(['dojo/Evented'], {
&amp;nbsp; constructor: function(x, y) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.x = x;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.y = y;
&amp;nbsp; }
&amp;nbsp; dispatch: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.emit('myEvent', {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message: 'This is a test message.',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result: this.x + this.y
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp; }
});

var myInstance = new MySumClass(5,10);
myInstance.on('myEvent', function(results) {
&amp;nbsp; console.log('message', results.message);
&amp;nbsp; console.log('results', results.result);
});
myInstance.dispatch(); // console logs print at this point
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;This also gives you the ability to to use dojo/on with dojo/Evented&lt;BR /&gt;&lt;A href="http://livedocs.dojotoolkit.org/dojo/on" rel="nofollow noopener noreferrer" target="_blank"&gt;http://livedocs.dojotoolkit.org/dojo/on&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This opens up some cool uses where you can listen for events only once, pause them, remove them and so on.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&amp;nbsp; odoe for giving a reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I did not explain my requirement properly. What I was searching is, dispatching a predefined event of the ESRI map from a java script function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Scenario is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have function in Java script and I need to dispatch a&amp;nbsp; "onZoom" event already connect to the ESRI map when the map is&amp;nbsp;&amp;nbsp;&amp;nbsp; created and invoke the associated handler connected to the zoom event.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:24:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/firing-a-event-or-dispatching-a-event/m-p/159246#M14862</guid>
      <dc:creator>ShashankA</dc:creator>
      <dc:date>2021-12-11T08:24:41Z</dc:date>
    </item>
  </channel>
</rss>

