<?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 disable an &amp;quot;on&amp;quot; event? in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771724#M1722</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't get it to work - the event is over &lt;STRONG&gt;this.map&lt;/STRONG&gt; which is not a DOM node and thus doesn't contain &lt;STRONG&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;removeEventListener&lt;/CODE&gt;&lt;/STRONG&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;, or misses the right node (I tried &lt;STRONG&gt;this.map.container.removeEventListener("click", this.onMapClick, true);&lt;/STRONG&gt;). The function &lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;&lt;STRONG&gt;this.onMapClick&lt;/STRONG&gt; still runs when it shouldn't.&lt;/CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But thanks for pointing to this function, Robert!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Apr 2016 14:20:17 GMT</pubDate>
    <dc:creator>PavelVeselský1</dc:creator>
    <dc:date>2016-04-12T14:20:17Z</dc:date>
    <item>
      <title>How to disable an "on" event?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771722#M1720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only way I know to disable (or better, remove, I don't need to re-enable it) an &lt;CODE&gt;on&lt;/CODE&gt; event in dojo is to &lt;A href="https://developers.arcgis.com/javascript/jshelp/inside_events.html" rel="nofollow noopener noreferrer" target="_blank"&gt;use a handle&lt;/A&gt;, like this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;var myUnload = map.on("unload", unloadHandler); 
myUnload.remove(); &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In Web AppBuilder, event handlers are supposed to be made through &lt;CODE&gt;this.own&lt;/CODE&gt;, at least this method is used in all the widgets by ESRI. How to disable such events? Setting a handle doesn't seem possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What exactly does &lt;CODE&gt;this.own&lt;/CODE&gt; do? If I understand it right, it should save the event somewhere into the widget. But where? How can I remove it from there?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:37:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771722#M1720</guid>
      <dc:creator>PavelVeselský1</dc:creator>
      <dc:date>2021-12-12T08:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable an "on" event?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771723#M1721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pavel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; This.own is a way for a widget to destroy/remove events when the widget it destroyed. &lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;EM style="color: #000000; font-family: Verdana, Geneva, Helvetica, Arial, sans-serif; font-size: 13.44px;"&gt;The advantage of using own() in the widget infrastructure is that internally, the widget can keep track of all of its handles, and make sure everything is disconnected and/or unsubscribed when the widget is destroyed—preventing any kind of memory leaks.&lt;/EM&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You can use JS removeEventListener in modern browsers if you know the event and function that the event is calling:&lt;/P&gt;&lt;P&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;node.removeEventListener ("click", clickFunction, false);&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Apr 2016 13:14:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771723#M1721</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-04-12T13:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable an "on" event?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771724#M1722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't get it to work - the event is over &lt;STRONG&gt;this.map&lt;/STRONG&gt; which is not a DOM node and thus doesn't contain &lt;STRONG&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;removeEventListener&lt;/CODE&gt;&lt;/STRONG&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;, or misses the right node (I tried &lt;STRONG&gt;this.map.container.removeEventListener("click", this.onMapClick, true);&lt;/STRONG&gt;). The function &lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;&lt;STRONG&gt;this.onMapClick&lt;/STRONG&gt; still runs when it shouldn't.&lt;/CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But thanks for pointing to this function, Robert!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Apr 2016 14:20:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771724#M1722</guid>
      <dc:creator>PavelVeselský1</dc:creator>
      <dc:date>2016-04-12T14:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable an "on" event?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771725#M1723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pavel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I doubt that it would work but,&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14604711276041932 jive_text_macro" data-renderedposition="86_8_1332_16" jivemacro_uid="_14604711276041932"&gt;&lt;P&gt;this.map.domNode.removeEventListener("click", this.onMapClick, true);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;may be worth a try.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Apr 2016 14:27:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771725#M1723</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-04-12T14:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable an "on" event?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771726#M1724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you use the &lt;A href="https://dojotoolkit.org/reference-guide/1.10/dojo/on.html#pausable"&gt;pausable&lt;/A&gt; method of "&lt;A href="https://dojotoolkit.org/reference-guide/1.10/dojo/on.html"&gt;dojo/on&lt;/A&gt;", since its target doesn't need to be a DOM node?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;...the target object (a DOM node or other event emitting object) that will be the source of the event. The target object may be a host object with its own event capabilities (like DOM elements or the window), or it may be a JavaScript object with an &lt;CODE class="docutils literal"&gt;&lt;SPAN class="pre"&gt;on()&lt;/SPAN&gt;&lt;/CODE&gt; method.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Apr 2016 16:08:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771726#M1724</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2016-04-12T16:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable an "on" event?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771727#M1725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pavel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; OK, I slowed down and re-read your original post a couple of time and I think what you are wanting is achieved by this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14604779419899226 jive_text_macro" data-renderedposition="112_8_1155_16" jivemacro_uid="_14604779419899226"&gt;&lt;P&gt;this.own(this.mapClickEvent = this.map.on('click', lang.hitch(this, this.mapClickEvtHandler)));&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Apr 2016 16:19:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771727#M1725</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-04-12T16:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable an "on" event?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771728#M1726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It needs some handler which I didn't have, so I accepted Robert's answer as "correct". In practice, I will use your answer as well, reusing listeners is a good practice and my case it will be very helpful. Thanks, Ken!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2016 05:44:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-an-quot-on-quot-event/m-p/771728#M1726</guid>
      <dc:creator>PavelVeselský1</dc:creator>
      <dc:date>2016-04-13T05:44:20Z</dc:date>
    </item>
  </channel>
</rss>

