<?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: when is widget added to the DOM? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/when-is-widget-added-to-the-dom/m-p/1408976#M84303</link>
    <description>&lt;P&gt;Yeah, thank you, it kind of resolves my issue. But for me it seems that callback inside editor.when(() =&amp;gt; {})&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;doesn't really invokes after something was done about editor widget.&lt;/P&gt;&lt;P&gt;I tried to subscribe in different places&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;// I did on page load&lt;BR /&gt;&lt;BR /&gt;const &lt;/SPAN&gt;editor = &lt;SPAN&gt;new &lt;/SPAN&gt;Editor({&lt;BR /&gt;  &lt;SPAN&gt;view&lt;/SPAN&gt;: view&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;  &lt;SPAN&gt;id&lt;/SPAN&gt;: &lt;SPAN&gt;EDITOR_ID&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;})&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;editor.&lt;SPAN&gt;when&lt;/SPAN&gt;(() =&amp;gt; {&lt;BR /&gt;  console.log(1);&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;})&lt;SPAN&gt;;&lt;BR /&gt;// then in on button click &lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;PRE&gt;view.&lt;SPAN&gt;ui&lt;/SPAN&gt;.&lt;SPAN&gt;add&lt;/SPAN&gt;(editor&lt;SPAN&gt;, &lt;/SPAN&gt;position)&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;// and again&lt;BR /&gt;&lt;BR /&gt;editor.when(() =&amp;gt; {&lt;BR /&gt;  console.log(2);&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;// and just for testing nothing doing with editor after button click&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;setTimeout&lt;/SPAN&gt;(() =&amp;gt; {&lt;BR /&gt;  editorWidget.&lt;SPAN&gt;when&lt;/SPAN&gt;(() =&amp;gt; {&lt;BR /&gt;    console.log(3);&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;  })&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;}&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;5000&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;// Each callback happend ones, and in console I got output 1, 2, 3&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 12 Apr 2024 14:14:57 GMT</pubDate>
    <dc:creator>AnastasiiaDzundza</dc:creator>
    <dc:date>2024-04-12T14:14:57Z</dc:date>
    <item>
      <title>when is widget added to the DOM?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/when-is-widget-added-to-the-dom/m-p/1408075#M84280</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a situation when I query&amp;nbsp; Editor widget's element after it's added to the the map&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;const &lt;/SPAN&gt;widgetDom = &lt;SPAN&gt;document&lt;/SPAN&gt;.&lt;SPAN&gt;getElementsByClassName&lt;/SPAN&gt;('esri-editor')[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;In case when I do it&amp;nbsp; after a while the page was loaded it happens successfully. But when I do right&amp;nbsp; after the page is loaded (also after Editor widget is added to the view)&amp;nbsp; it returns "undefined". I don't get what's the difference. Why it works fine in one case but doesn’t in another. Is there any event I can subscribe to make sure the widget is added to the DOM?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2024 17:45:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/when-is-widget-added-to-the-dom/m-p/1408075#M84280</guid>
      <dc:creator>AnastasiiaDzundza</dc:creator>
      <dc:date>2024-04-10T17:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: when is widget added to the DOM?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/when-is-widget-added-to-the-dom/m-p/1408572#M84293</link>
      <description>&lt;P&gt;Yes, when is the answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;when()&lt;/FONT&gt; may be leveraged once an instance of the class is created.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#methods-summary" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#methods-summary&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;Example&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;// Although this example uses the BasemapGallery widget, any class instance that is a promise may use when() in the same way&lt;/SPAN&gt;
&lt;SPAN class=""&gt;let&lt;/SPAN&gt; bmGallery = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;BasemapGallery&lt;/SPAN&gt;();
bmGallery.&lt;SPAN class=""&gt;when&lt;/SPAN&gt;(&lt;SPAN class=""&gt;function&lt;/SPAN&gt;(){
  &lt;SPAN class=""&gt;// This function will execute once the promise is resolved&lt;/SPAN&gt;
}, &lt;SPAN class=""&gt;function&lt;/SPAN&gt;(&lt;SPAN class=""&gt;error&lt;/SPAN&gt;){
  &lt;SPAN class=""&gt;// This function will execute if the promise is rejected due to an error&lt;/SPAN&gt;
});&lt;/PRE&gt;&lt;P&gt;Does this solve the issue?&lt;/P&gt;&lt;P&gt;Egge-Jan&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 11 Apr 2024 15:57:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/when-is-widget-added-to-the-dom/m-p/1408572#M84293</guid>
      <dc:creator>Egge-Jan_Pollé</dc:creator>
      <dc:date>2024-04-11T15:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: when is widget added to the DOM?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/when-is-widget-added-to-the-dom/m-p/1408976#M84303</link>
      <description>&lt;P&gt;Yeah, thank you, it kind of resolves my issue. But for me it seems that callback inside editor.when(() =&amp;gt; {})&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;doesn't really invokes after something was done about editor widget.&lt;/P&gt;&lt;P&gt;I tried to subscribe in different places&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;// I did on page load&lt;BR /&gt;&lt;BR /&gt;const &lt;/SPAN&gt;editor = &lt;SPAN&gt;new &lt;/SPAN&gt;Editor({&lt;BR /&gt;  &lt;SPAN&gt;view&lt;/SPAN&gt;: view&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;  &lt;SPAN&gt;id&lt;/SPAN&gt;: &lt;SPAN&gt;EDITOR_ID&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;})&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;editor.&lt;SPAN&gt;when&lt;/SPAN&gt;(() =&amp;gt; {&lt;BR /&gt;  console.log(1);&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;})&lt;SPAN&gt;;&lt;BR /&gt;// then in on button click &lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;PRE&gt;view.&lt;SPAN&gt;ui&lt;/SPAN&gt;.&lt;SPAN&gt;add&lt;/SPAN&gt;(editor&lt;SPAN&gt;, &lt;/SPAN&gt;position)&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;// and again&lt;BR /&gt;&lt;BR /&gt;editor.when(() =&amp;gt; {&lt;BR /&gt;  console.log(2);&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;// and just for testing nothing doing with editor after button click&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;setTimeout&lt;/SPAN&gt;(() =&amp;gt; {&lt;BR /&gt;  editorWidget.&lt;SPAN&gt;when&lt;/SPAN&gt;(() =&amp;gt; {&lt;BR /&gt;    console.log(3);&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;  })&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;}&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;5000&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;// Each callback happend ones, and in console I got output 1, 2, 3&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 12 Apr 2024 14:14:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/when-is-widget-added-to-the-dom/m-p/1408976#M84303</guid>
      <dc:creator>AnastasiiaDzundza</dc:creator>
      <dc:date>2024-04-12T14:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: when is widget added to the DOM?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/when-is-widget-added-to-the-dom/m-p/1408978#M84304</link>
      <description>&lt;P&gt;I hope you get sequence of action I was doing. For me in such case feels like when is acting the same as setTimeout.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 14:20:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/when-is-widget-added-to-the-dom/m-p/1408978#M84304</guid>
      <dc:creator>AnastasiiaDzundza</dc:creator>
      <dc:date>2024-04-12T14:20:13Z</dc:date>
    </item>
  </channel>
</rss>

