<?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: Widget.destroy() is destroying too much in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-destroy-is-destroying-too-much/m-p/1006705#M70980</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/413496"&gt;@KevinMacLeodCAI&lt;/a&gt;&amp;nbsp;sorry, just saw this.&amp;nbsp; We can try to find a workaround here, but you might also consider creating a ticket via Tech Support so these dev usability issues get into the system.&amp;nbsp; I've recently used the Measurement related widgets in several apps, both using the&amp;nbsp;view.ui.add(...) technique and in a side panel outside of the view.&amp;nbsp; I never try to destroy the widget; the UI is always around.&amp;nbsp; If you want to clear existing measurement results and graphics, you can call the &lt;STRONG&gt;clear()&lt;/STRONG&gt; method.&amp;nbsp; Do you have a codepen showing the issue?&lt;/P&gt;</description>
    <pubDate>Thu, 03 Dec 2020 18:41:13 GMT</pubDate>
    <dc:creator>JohnGrayson</dc:creator>
    <dc:date>2020-12-03T18:41:13Z</dc:date>
    <item>
      <title>Widget.destroy() is destroying too much</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-destroy-is-destroying-too-much/m-p/608952#M56977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Howdy all!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been practicing with the BasemapGallery widget. I wanted to make a button that destroys or creates the widget, so i could "hide" and "show" the widget. The BasemapGallery is pretty big, screen space wise, so I just want a way to get it out of the way when it isn't needed. &amp;nbsp;I did this by creating a &amp;lt;div&amp;gt; element, then assigning the "hide" button and the widget to it. In my code, all the button does is destroy the widget (I'll figure out how to bring it back later). However, when I click the button, both the widget and the button get destroyed. Why is my basemapGallery.destroy() command so bloodthirsty? Below is the code I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;//initialization of the basemapGallery widget&lt;BR /&gt; var basemapDom = domConstruct.toDom("&amp;lt;div id='divContainer'&amp;gt;&amp;lt;/div&amp;gt;");&lt;BR /&gt; var basemapGallery = new BasemapGallery({&lt;BR /&gt; view: view,&lt;BR /&gt; container: basemapDom&lt;BR /&gt; });&lt;BR /&gt; //BasemapGallery hide button is being defined&lt;BR /&gt; watchUtils.whenDefinedOnce(basemapGallery, "viewModel", function (evt) {&lt;BR /&gt; //trying to create a div element and place the button and widgit inside of it&lt;/P&gt;&lt;P&gt;var buttonDom = domConstruct.create("button",&lt;BR /&gt; { class: 'basemapGallery', type: 'button', innerHTML: 'Basemaps'},&lt;BR /&gt; basemapDom, "first");&lt;BR /&gt; on(buttonDom, 'click', function () {&lt;BR /&gt; basemapGallery.destroy();&lt;BR /&gt; });&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;view.ui.add(basemapDom, {&lt;BR /&gt; position: "top-right"&lt;BR /&gt; });&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks for taking a look at this&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Aug 2017 21:07:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-destroy-is-destroying-too-much/m-p/608952#M56977</guid>
      <dc:creator>GregSalvador</dc:creator>
      <dc:date>2017-08-21T21:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Widget.destroy() is destroying too much</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-destroy-is-destroying-too-much/m-p/608953#M56978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using the Expand widget:&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html" title="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html"&gt;Expand | API Reference | ArcGIS API for JavaScript 4.4&lt;/A&gt;&amp;nbsp;&amp;amp; &amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/sample-code/widgets-expand/index.html" title="https://developers.arcgis.com/javascript/latest/sample-code/widgets-expand/index.html"&gt;Expand widget | ArcGIS API for JavaScript 4.4&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Aug 2017 00:31:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-destroy-is-destroying-too-much/m-p/608953#M56978</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2017-08-22T00:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Widget.destroy() is destroying too much</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-destroy-is-destroying-too-much/m-p/1000901#M70791</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/11373"&gt;@JohnGrayson&lt;/a&gt;&amp;nbsp; does expand destroy the widget? I want to remove a measurement widget instance so as to remove its click handlers, on-screen graphics, etc.&amp;nbsp; Basically I want to take the Measurement example and put it in a side panel in a dom node. Of course out of the box; this does not work as this thread describes, because the widget destroys its own container. I've struggled with trying to use plain JS or jQuery to create a dom node; then append and move the widget to it; no dice.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When widgets are added with the view.ui.add it doesn't do this. But when you add them to a DOM node; it adds esri classes to the&amp;nbsp;&lt;STRONG&gt;container&lt;/STRONG&gt; node itself. I suspect the destroy method looks for these classes and queries, to decide what to destroy. I agree with original poster. It goes one level up too high. Destroying a widget should&amp;nbsp;&lt;STRONG&gt;not&amp;nbsp;&lt;/STRONG&gt;destroy its container. Nor should a container get polluted with classes from a widget it contains, they should be separate. Furthermore it would be nice to have a unified click handling for widgets with a default where if you start measuring, Draw stops listening, other widgets stop listening etc. Have that on by default with ability to turn off 'smart' clicking handling.&amp;nbsp; This widget destroy() container issue is relevant for just about any widget.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Meantime maybe I'll do a hack of a way to do it; try moving the element from view.ui and appending to the panel after it gets rendered.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 21:37:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-destroy-is-destroying-too-much/m-p/1000901#M70791</guid>
      <dc:creator>KevinMacLeodCAI</dc:creator>
      <dc:date>2020-11-12T21:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Widget.destroy() is destroying too much</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-destroy-is-destroying-too-much/m-p/1001348#M70811</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/11373"&gt;@JohnGrayson&lt;/a&gt;&amp;nbsp; is there an example sample with a Measure widget being put in to an existing DOM node? Where it won't destroy its container when it gets removed with the .destroy() method?&amp;nbsp; I tried Expand and predictably all it does is hide the interface, it has no effect on the graphics or click handlers.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 19:22:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-destroy-is-destroying-too-much/m-p/1001348#M70811</guid>
      <dc:creator>KevinMacLeodCAI</dc:creator>
      <dc:date>2020-11-13T19:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Widget.destroy() is destroying too much</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-destroy-is-destroying-too-much/m-p/1006705#M70980</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/413496"&gt;@KevinMacLeodCAI&lt;/a&gt;&amp;nbsp;sorry, just saw this.&amp;nbsp; We can try to find a workaround here, but you might also consider creating a ticket via Tech Support so these dev usability issues get into the system.&amp;nbsp; I've recently used the Measurement related widgets in several apps, both using the&amp;nbsp;view.ui.add(...) technique and in a side panel outside of the view.&amp;nbsp; I never try to destroy the widget; the UI is always around.&amp;nbsp; If you want to clear existing measurement results and graphics, you can call the &lt;STRONG&gt;clear()&lt;/STRONG&gt; method.&amp;nbsp; Do you have a codepen showing the issue?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 18:41:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-destroy-is-destroying-too-much/m-p/1006705#M70980</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2020-12-03T18:41:13Z</dc:date>
    </item>
  </channel>
</rss>

