<?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 Read content of popup after opening in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/read-content-of-popup-after-opening/m-p/1311854#M81779</link>
    <description>&lt;P&gt;I'm working with Arcgis version 4.27 and want to set click function for the content of the popup after opening the popup. As I understand, the best way is "&lt;STRONG&gt;reactiveUtils&lt;/STRONG&gt;" but doesn't work properly and the length of the "$(".tblInfoWindow").find("img.Question")" is zero.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code is:&lt;/P&gt;&lt;P&gt;reactiveUtils.watch(&lt;BR /&gt;() =&amp;gt; mainView.popup.visible,&lt;BR /&gt;(visible) =&amp;gt; {&lt;BR /&gt;if (visible) {&lt;BR /&gt;console.log($(".tblInfoWindow").find("img.Question").length);&lt;BR /&gt;$(".tblInfoWindow").find("img.Question").click(function () {&lt;BR /&gt;var layerID = $(this).attr("id").replace("question_layer", "");&lt;BR /&gt;var layerName = $.trim($(this).parent().text());&lt;/P&gt;&lt;P&gt;OpenQuestionLink(layerID, layerName);&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;How can I set click function for the content of the popup after opening that? Seems visible=true before opening the popup!&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jul 2023 02:02:02 GMT</pubDate>
    <dc:creator>samitalebi</dc:creator>
    <dc:date>2023-07-26T02:02:02Z</dc:date>
    <item>
      <title>Read content of popup after opening</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/read-content-of-popup-after-opening/m-p/1311854#M81779</link>
      <description>&lt;P&gt;I'm working with Arcgis version 4.27 and want to set click function for the content of the popup after opening the popup. As I understand, the best way is "&lt;STRONG&gt;reactiveUtils&lt;/STRONG&gt;" but doesn't work properly and the length of the "$(".tblInfoWindow").find("img.Question")" is zero.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code is:&lt;/P&gt;&lt;P&gt;reactiveUtils.watch(&lt;BR /&gt;() =&amp;gt; mainView.popup.visible,&lt;BR /&gt;(visible) =&amp;gt; {&lt;BR /&gt;if (visible) {&lt;BR /&gt;console.log($(".tblInfoWindow").find("img.Question").length);&lt;BR /&gt;$(".tblInfoWindow").find("img.Question").click(function () {&lt;BR /&gt;var layerID = $(this).attr("id").replace("question_layer", "");&lt;BR /&gt;var layerName = $.trim($(this).parent().text());&lt;/P&gt;&lt;P&gt;OpenQuestionLink(layerID, layerName);&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;How can I set click function for the content of the popup after opening that? Seems visible=true before opening the popup!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 02:02:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/read-content-of-popup-after-opening/m-p/1311854#M81779</guid>
      <dc:creator>samitalebi</dc:creator>
      <dc:date>2023-07-26T02:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Read content of popup after opening</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/read-content-of-popup-after-opening/m-p/1312170#M81788</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/657042"&gt;@samitalebi&lt;/a&gt;&amp;nbsp;-&lt;/P&gt;&lt;P&gt;You can try to watch when the view.popup.selectedFeature changes using reactiveUtils:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;reactiveUtils.when(() =&amp;gt; view.popup?.selectedFeature, () =&amp;gt; {
  console.log(view.popup.selectedFeature)
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example CodePen shows how to access that:&amp;nbsp;&lt;A href="https://codepen.io/laurenb14/pen/yLQRgGM?editors=1000" target="_blank"&gt;https://codepen.io/laurenb14/pen/yLQRgGM?editors=1000&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that doesn't work, could you please send a CodePen with an example of what you are trying to achieve?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 17:42:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/read-content-of-popup-after-opening/m-p/1312170#M81788</guid>
      <dc:creator>LaurenBoyd</dc:creator>
      <dc:date>2023-07-26T17:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: Read content of popup after opening</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/read-content-of-popup-after-opening/m-p/1312192#M81791</link>
      <description>&lt;P&gt;The issue appears to be that just because the visible property changes to true, it doesn't mean the content has yet been added to the popup, and therefore queryable through the DOM. Since the popup doesn't have the equivalent of a "content-ready" event, we have to be a little more creative. I recommend something like the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;new MutationObserver(function() {
	if (popup.visible) {
		var button = document.querySelector("myButtonSelector");

		if ((button) &amp;amp;&amp;amp; (button.dataset.addedclick != "true")) {
			button.dataset.addedclick = "true"; //flag to indicate we've set the handler, so action doesn't get repeated unnecessarily
			button.onclick = function() {
				//do something
			};
		}
	}
}).observe(popup.container, {childList:true,subtree:true});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 18:13:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/read-content-of-popup-after-opening/m-p/1312192#M81791</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-07-26T18:13:38Z</dc:date>
    </item>
  </channel>
</rss>

