<?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 modify InfoTemplate content dynamically when it's displayed in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-modify-infotemplate-content-dynamically/m-p/157626#M14723</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Something like this?&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
map.graphics.enableMouseEvents();
dojo.connect(map.graphics, "onClick", function(evt) {
&amp;nbsp;&amp;nbsp; // Set your events on the pop up as you want
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;I am not sure exactly when this is fired in comparison to the info popup opening, but I would start here and see if it suits your needs.&amp;nbsp; In &lt;A href="http://forums.arcgis.com/threads/56616-Selecting-PDF-to-view-from-datagrid-result?p=194918&amp;amp;viewfull=1#post194918" rel="nofollow noopener noreferrer" target="_blank"&gt;this example&lt;/A&gt; I set the entire content of the popup on graphic click, and it functioned well, but it was a simple example.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the inspiration Tom. Your solution and a few others I attempted after this post didn't work. In fact I ended up trying pretty complex solutions (e.g. mutation events) before I stopped what I was doing and remembered the KISS principle. Taking a few steps back, I realized that what I was trying to avoid is have some unique HTML content for every single InfoTemplate (one per layer), I wanted a one fits all solution. I also wanted to avoid coding a onclick handler for my custom button directly in this HTML (I haven't used static handlers like that for ages). Therefore I resisted the idea, but it does seem to be the simplest solution, so I think I'll go with that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like this, one content per layer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
// InfoTemplate content
&amp;lt;div id="layer-conduitAqueduc-popup" style="display: none;"&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;table class="popup-table"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tbody&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Identifiant&amp;lt;/td&amp;gt;&amp;lt;td class="right-align"&amp;gt;${IdCondt}&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tbody&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;br /&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;div data-role="button" data-mini="true" onclick="_Layer.onInspectionClick(Couche.CONDUIT_D_AQUEDUC);"&amp;gt;Inspection&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should be x-browser too.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 08:20:53 GMT</pubDate>
    <dc:creator>YohanBienvenue</dc:creator>
    <dc:date>2021-12-11T08:20:53Z</dc:date>
    <item>
      <title>How to modify InfoTemplate content dynamically when it's displayed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-modify-infotemplate-content-dynamically/m-p/157624#M14721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have several feature layers in my map, and each of them have graphics that when clicked display a different InfoTemplate.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I saw that whenever a popup is displayed, the &amp;lt;div class="esriPopup"&amp;gt; element's content is updated with the correct infoTemplate content (depending on the graphic clicked).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, I'd like to be able to dynamically edit this content when the popup is displayed, for instance maybe do things like that:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;$(".esriPopup").find(".popup-button").on("vmousedown", function(){ // do things });&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // popup button onclick&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but to do this I need to know when the DOM has finished updating&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TLDR: Is there any ArcGIS for Javascript API event I could bind to so that I could execute some of my code when a popup is displayed?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 14:54:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-modify-infotemplate-content-dynamically/m-p/157624#M14721</guid>
      <dc:creator>YohanBienvenue</dc:creator>
      <dc:date>2012-05-08T14:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify InfoTemplate content dynamically when it's displayed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-modify-infotemplate-content-dynamically/m-p/157625#M14722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Something like this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
map.graphics.enableMouseEvents();
dojo.connect(map.graphics, "onClick", function(evt) {
&amp;nbsp;&amp;nbsp; // Set your events on the pop up as you want
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not sure exactly when this is fired in comparison to the info popup opening, but I would start here and see if it suits your needs.&amp;nbsp; In &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/56616-Selecting-PDF-to-view-from-datagrid-result?p=194918&amp;amp;viewfull=1#post194918" rel="nofollow noopener noreferrer" target="_blank"&gt;this example&lt;/A&gt;&lt;SPAN&gt; I set the entire content of the popup on graphic click, and it functioned well, but it was a simple example.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:20:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-modify-infotemplate-content-dynamically/m-p/157625#M14722</guid>
      <dc:creator>TomJacoby</dc:creator>
      <dc:date>2021-12-11T08:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify InfoTemplate content dynamically when it's displayed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-modify-infotemplate-content-dynamically/m-p/157626#M14723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Something like this?&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
map.graphics.enableMouseEvents();
dojo.connect(map.graphics, "onClick", function(evt) {
&amp;nbsp;&amp;nbsp; // Set your events on the pop up as you want
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;I am not sure exactly when this is fired in comparison to the info popup opening, but I would start here and see if it suits your needs.&amp;nbsp; In &lt;A href="http://forums.arcgis.com/threads/56616-Selecting-PDF-to-view-from-datagrid-result?p=194918&amp;amp;viewfull=1#post194918" rel="nofollow noopener noreferrer" target="_blank"&gt;this example&lt;/A&gt; I set the entire content of the popup on graphic click, and it functioned well, but it was a simple example.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the inspiration Tom. Your solution and a few others I attempted after this post didn't work. In fact I ended up trying pretty complex solutions (e.g. mutation events) before I stopped what I was doing and remembered the KISS principle. Taking a few steps back, I realized that what I was trying to avoid is have some unique HTML content for every single InfoTemplate (one per layer), I wanted a one fits all solution. I also wanted to avoid coding a onclick handler for my custom button directly in this HTML (I haven't used static handlers like that for ages). Therefore I resisted the idea, but it does seem to be the simplest solution, so I think I'll go with that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like this, one content per layer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
// InfoTemplate content
&amp;lt;div id="layer-conduitAqueduc-popup" style="display: none;"&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;table class="popup-table"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tbody&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Identifiant&amp;lt;/td&amp;gt;&amp;lt;td class="right-align"&amp;gt;${IdCondt}&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tbody&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;br /&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;div data-role="button" data-mini="true" onclick="_Layer.onInspectionClick(Couche.CONDUIT_D_AQUEDUC);"&amp;gt;Inspection&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should be x-browser too.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:20:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-modify-infotemplate-content-dynamically/m-p/157626#M14723</guid>
      <dc:creator>YohanBienvenue</dc:creator>
      <dc:date>2021-12-11T08:20:53Z</dc:date>
    </item>
  </channel>
</rss>

