<?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: Does the JavaScript API support event handling via &amp;quot;on&amp;quot; method? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57615#M5074</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Custom events won't work, but you can actually use dojo/on for native events on things like a "click" event and do some useful things. Other events, like "load" won't work yet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a sample of how you might use dojo/on to handle multple map click events, like say you want to switch between identify on a map and draw on a map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://gist.github.com/odoe/4542944" rel="nofollow noopener noreferrer" target="_blank"&gt;https://gist.github.com/odoe/4542944&lt;/A&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
// Purely sample
// Just demonstrates how you may use the dojo/on method
// with the map click and other click events

define('identifyHandler', ['dojo/on', 'esri/tasks/identify'], function(on) {

&amp;nbsp; var _idhandler = function(map) {
&amp;nbsp; 
&amp;nbsp; var task = new esri.tasks.IdentifyTask('url');
&amp;nbsp; var idparams = new esri.tasks.IdentifyParameters();
&amp;nbsp; idparams.tolerance = 3;
&amp;nbsp; idparams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
&amp;nbsp; // callback train, yeah yeah, it's a sample, jeez
&amp;nbsp; this.handler = on.pausable(map, 'click', function(e) {
&amp;nbsp; 
&amp;nbsp;&amp;nbsp; // blah blah, set up your Identify Parameters
&amp;nbsp;&amp;nbsp; var deferred = task.execute(idparams);
&amp;nbsp;&amp;nbsp; deferred.then(function(){
&amp;nbsp;&amp;nbsp;&amp;nbsp; // blah blah, do something
&amp;nbsp;&amp;nbsp; });
&amp;nbsp; 
&amp;nbsp; });
&amp;nbsp; 
 };
 
 return _idhandler;

});

define('mapView', ['dojo/connect', 'identifyHandler', 'esri/map', 'esri/toolbars/draw'], function(connect, IdHandler) {

 var _mapview = function() {
 
&amp;nbsp; var self = this;
&amp;nbsp; this.start = function() {
&amp;nbsp; 
&amp;nbsp;&amp;nbsp; self.map = new esri.Map('map');
&amp;nbsp;&amp;nbsp; /**
&amp;nbsp;&amp;nbsp; do a bunch of map stuff
&amp;nbsp;&amp;nbsp; **/
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; connect.connect(self.map, 'onLoad', function() {
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; // initialize my little identify helper module
&amp;nbsp;&amp;nbsp;&amp;nbsp; var identify = new IdHandler(self.map);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; /**
&amp;nbsp;&amp;nbsp;&amp;nbsp; Now, let's say you have a drawtool that will add points
&amp;nbsp;&amp;nbsp;&amp;nbsp; to your map for some reason. A common problem is you can add the point,
&amp;nbsp;&amp;nbsp;&amp;nbsp; but the map click to add a point also triggers the identify.
&amp;nbsp;&amp;nbsp;&amp;nbsp; Easy way to handle this now...
&amp;nbsp;&amp;nbsp;&amp;nbsp; **/
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var drawTool = new esri.toolbars.Draw(map);
&amp;nbsp;&amp;nbsp;&amp;nbsp; /** draw nonsense stuff here somewhere **/
&amp;nbsp;&amp;nbsp;&amp;nbsp; connect.connect(someButton, 'click', function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drawTool.activate(esri.toolbars.Draw.POINT);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // now pause the identify map click
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; identify.handler.pause();
&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; connect.connect(drawTool, 'onDrawEnd', function(geom) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drawTool.deactivate();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // turn the identify back on
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; identify.handler.resume();
&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; };
 
 };
 
 return _mapview;

});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It can actually come in pretty handy. This has worked since the 3.0 release I think, because I tested it with 3.2. So I'm assuming since the upgrade to Dojo 1.7.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 22:10:59 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2021-12-10T22:10:59Z</dc:date>
    <item>
      <title>Does the JavaScript API support event handling via &amp;amp;amp;quot;on&amp;amp;amp;quot; method?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57612#M5071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;A class="jive-link-external-small" href="http://dojotoolkit.org/reference-guide/1.7/dojo/connect.html#id3" rel="nofollow" target="_blank"&gt;The dojo/on module has replaced the dojo.connect method as the preferred way to handle events in Dojo&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp; I am able to get the "on" method to work with DOM events (e.g., HTML button click), but I can't get it to work with any of the ArcGIS JavaScript API classes' events.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to use the on method with the ArcGIS JavaScript API events?&amp;nbsp; (If so, can you provide an example?)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2012 16:23:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57612#M5071</guid>
      <dc:creator>JeffJacobson</dc:creator>
      <dc:date>2012-08-21T16:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Does the JavaScript API support event handling via "on" method?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57613#M5072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No, objects in the JS API don't support using dojo/on yet. Please continue to use dojo/_base/connect.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2012 17:17:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57613#M5072</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2012-08-21T17:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Does the JavaScript API support event handling via "on" method?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57614#M5073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the Version 3.3 of the ArcGIS API for JavaScript uses Dojo 1.8 but the dojo/on still does not work with the map object. It works wth dojo/_base/connect but it would be nice to use the new event handling and not the stuff that is supported cause of backwards compatiblity.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have any information when dojo/on will work with the map object and the JS API will completely support Dojo 1.8?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Stefan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Feb 2013 08:54:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57614#M5073</guid>
      <dc:creator>StefanP__Jung</dc:creator>
      <dc:date>2013-02-05T08:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: Does the JavaScript API support event handling via "on" method?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57615#M5074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Custom events won't work, but you can actually use dojo/on for native events on things like a "click" event and do some useful things. Other events, like "load" won't work yet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a sample of how you might use dojo/on to handle multple map click events, like say you want to switch between identify on a map and draw on a map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://gist.github.com/odoe/4542944" rel="nofollow noopener noreferrer" target="_blank"&gt;https://gist.github.com/odoe/4542944&lt;/A&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
// Purely sample
// Just demonstrates how you may use the dojo/on method
// with the map click and other click events

define('identifyHandler', ['dojo/on', 'esri/tasks/identify'], function(on) {

&amp;nbsp; var _idhandler = function(map) {
&amp;nbsp; 
&amp;nbsp; var task = new esri.tasks.IdentifyTask('url');
&amp;nbsp; var idparams = new esri.tasks.IdentifyParameters();
&amp;nbsp; idparams.tolerance = 3;
&amp;nbsp; idparams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
&amp;nbsp; // callback train, yeah yeah, it's a sample, jeez
&amp;nbsp; this.handler = on.pausable(map, 'click', function(e) {
&amp;nbsp; 
&amp;nbsp;&amp;nbsp; // blah blah, set up your Identify Parameters
&amp;nbsp;&amp;nbsp; var deferred = task.execute(idparams);
&amp;nbsp;&amp;nbsp; deferred.then(function(){
&amp;nbsp;&amp;nbsp;&amp;nbsp; // blah blah, do something
&amp;nbsp;&amp;nbsp; });
&amp;nbsp; 
&amp;nbsp; });
&amp;nbsp; 
 };
 
 return _idhandler;

});

define('mapView', ['dojo/connect', 'identifyHandler', 'esri/map', 'esri/toolbars/draw'], function(connect, IdHandler) {

 var _mapview = function() {
 
&amp;nbsp; var self = this;
&amp;nbsp; this.start = function() {
&amp;nbsp; 
&amp;nbsp;&amp;nbsp; self.map = new esri.Map('map');
&amp;nbsp;&amp;nbsp; /**
&amp;nbsp;&amp;nbsp; do a bunch of map stuff
&amp;nbsp;&amp;nbsp; **/
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; connect.connect(self.map, 'onLoad', function() {
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; // initialize my little identify helper module
&amp;nbsp;&amp;nbsp;&amp;nbsp; var identify = new IdHandler(self.map);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; /**
&amp;nbsp;&amp;nbsp;&amp;nbsp; Now, let's say you have a drawtool that will add points
&amp;nbsp;&amp;nbsp;&amp;nbsp; to your map for some reason. A common problem is you can add the point,
&amp;nbsp;&amp;nbsp;&amp;nbsp; but the map click to add a point also triggers the identify.
&amp;nbsp;&amp;nbsp;&amp;nbsp; Easy way to handle this now...
&amp;nbsp;&amp;nbsp;&amp;nbsp; **/
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var drawTool = new esri.toolbars.Draw(map);
&amp;nbsp;&amp;nbsp;&amp;nbsp; /** draw nonsense stuff here somewhere **/
&amp;nbsp;&amp;nbsp;&amp;nbsp; connect.connect(someButton, 'click', function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drawTool.activate(esri.toolbars.Draw.POINT);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // now pause the identify map click
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; identify.handler.pause();
&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; connect.connect(drawTool, 'onDrawEnd', function(geom) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drawTool.deactivate();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // turn the identify back on
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; identify.handler.resume();
&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; };
 
 };
 
 return _mapview;

});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It can actually come in pretty handy. This has worked since the 3.0 release I think, because I tested it with 3.2. So I'm assuming since the upgrade to Dojo 1.7.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:10:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57615#M5074</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-10T22:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Does the JavaScript API support event handling via "on" method?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57616#M5075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Even for the click event in the map I am currently using, the following which works fine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;require(["dojo/_base/connect"], function(Connect){
&amp;nbsp;&amp;nbsp;&amp;nbsp; Connect.connect(map, "onClick", function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do something
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
});&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In future i hope that this will work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;require(["dojo/on"], function(On){
&amp;nbsp;&amp;nbsp;&amp;nbsp; On(map, "onClick", function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do something
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
});&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;at the moment this throws this exception: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Error: Target must be an event emitter&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cause i have to use the Connect for all the other events like you also did in your example (onLoad etc.) I will go on with this till the On is supported.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:11:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57616#M5075</guid>
      <dc:creator>StefanP__Jung</dc:creator>
      <dc:date>2021-12-10T22:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Does the JavaScript API support event handling via "on" method?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57617#M5076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We're moving to using &lt;/SPAN&gt;&lt;A href="http://livedocs.dojotoolkit.org/dojo/Evented" rel="nofollow noopener noreferrer" target="_blank"&gt;dojo/Evented&lt;/A&gt;&lt;SPAN&gt; for events in the future. Instead of the dojo.connect code you see now, you'll be able to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
map.on("click", function(e) {
&amp;nbsp; console.log("map was clicked: ", e, e.mapPoint);
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;hope&lt;/SPAN&gt;&lt;SPAN&gt; to have this in the next release (3.4) for all objects (map, layers, widgets, etc).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:11:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57617#M5076</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2021-12-10T22:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Does the JavaScript API support event handling via "on" method?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57618#M5077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much for your feedback.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Looking forward to it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Feb 2013 06:01:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/does-the-javascript-api-support-event-handling-via/m-p/57618#M5077</guid>
      <dc:creator>StefanP__Jung</dc:creator>
      <dc:date>2013-02-06T06:01:16Z</dc:date>
    </item>
  </channel>
</rss>

