<?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: Custom Pop-up, onClick is not rendering in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1252986#M80109</link>
    <description>&lt;P&gt;You can manually create the DOM elements and add them to the custom content of your popup, which would be the recommended way to do something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;popupTemplate: {
  title: "{name}",
  content: [
    {
      type: "custom",
      outFields: ["*"],
      creator(event) {
        const elem = document.createElement("div");
        const btn = document.createElement("button");
        btn.innerText = event.graphic.attributes.name;
        btn.addEventListener("click", () =&amp;gt; {
          alert(event.graphic.attributes.description);
        });
        elem.appendChild(btn);
        return elem;
      }
    }
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="https://codepen.io/odoe/pen/QWBVKMM?editors=0010" target="_blank"&gt;https://codepen.io/odoe/pen/QWBVKMM?editors=0010&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jan 2023 17:35:34 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2023-01-30T17:35:34Z</dc:date>
    <item>
      <title>Custom Pop-up, onClick is not rendering</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1252930#M80102</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I'm creating a custom pop-up, and the content is pure HTML. On that HTML content, I'm trying to put onClick but it is not rendering.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    } else {
        if (filteredProductList[i].productType == 'Permit') {
            popUpContent += "&amp;lt;a class='slds-button slds-button_brand'  href='#' onClick='return false;'&amp;gt;Sold Out&amp;lt;/a&amp;gt;";
        } else {
            popUpContent += "&amp;lt;a class='slds-button slds-button_brand' href='#' onClick='notifyMe('TEST')'&amp;gt;Notify Me&amp;lt;/a&amp;gt;";
            popUpContent += "&amp;lt;input type='button' class='slds-button slds-button_brand' onClick='notifyMe('TEST')'&amp;gt;Notify Me&amp;lt;/input&amp;gt;";
        }
    }
}

view.popup.open({
title: popUpTitle,
location: m_event.mapPoint,
content: popUpContent
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I check the created pop up I'm not able to see this onClick rendered.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="UgurcanErkal_0-1675094238128.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/61620i8A545533EBC52628/image-size/large?v=v2&amp;amp;px=999" role="button" title="UgurcanErkal_0-1675094238128.png" alt="UgurcanErkal_0-1675094238128.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it forbidden by Esri to create an element with onClick?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 15:58:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1252930#M80102</guid>
      <dc:creator>UgurcanErkal</dc:creator>
      <dc:date>2023-01-30T15:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Pop-up, onClick is not rendering</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1252961#M80106</link>
      <description>&lt;P&gt;Try using &lt;A href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals" target="_self"&gt;template strings&lt;/A&gt; instead. I can get an alert using this syntax&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;`&amp;lt;a class='slds-button slds-button_brand' href='#' onClick='alert("Sold Out");'&amp;gt;Sold Out&amp;lt;/a&amp;gt;`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 16:54:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1252961#M80106</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-01-30T16:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Pop-up, onClick is not rendering</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1252966#M80108</link>
      <description>&lt;P&gt;Yes, in version 4.14, ESRI added the HTML sanitizer which, among other things, prevents you from adding event handlers in your popup content.&amp;nbsp; See the final breaking change listed &lt;A href="https://developers.arcgis.com/javascript/latest/4.14/#breaking-changes" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Fortunately, if you prefer to decide for yourself what is and isn't permissible in your applications, it's fairly easy to bypass.&amp;nbsp; You'd just need to add the following somewhere near where your application starts up.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require(["esri/widgets/support/widgetUtils"], function(widgetUtils) {
	var sanitize = widgetUtils.renderingSanitizer.sanitize;

	widgetUtils.renderingSanitizer.sanitize = function(b, c) {
		return ((typeof b == "string") ? b : sanitize.call(this, b, c));
	};
});&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 30 Jan 2023 17:03:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1252966#M80108</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-01-30T17:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Pop-up, onClick is not rendering</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1252986#M80109</link>
      <description>&lt;P&gt;You can manually create the DOM elements and add them to the custom content of your popup, which would be the recommended way to do something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;popupTemplate: {
  title: "{name}",
  content: [
    {
      type: "custom",
      outFields: ["*"],
      creator(event) {
        const elem = document.createElement("div");
        const btn = document.createElement("button");
        btn.innerText = event.graphic.attributes.name;
        btn.addEventListener("click", () =&amp;gt; {
          alert(event.graphic.attributes.description);
        });
        elem.appendChild(btn);
        return elem;
      }
    }
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="https://codepen.io/odoe/pen/QWBVKMM?editors=0010" target="_blank"&gt;https://codepen.io/odoe/pen/QWBVKMM?editors=0010&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 17:35:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1252986#M80109</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2023-01-30T17:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Pop-up, onClick is not rendering</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1257452#M80230</link>
      <description>&lt;P&gt;Thank you, this works as expected!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 09:33:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1257452#M80230</guid>
      <dc:creator>UgurcanErkal</dc:creator>
      <dc:date>2023-02-13T09:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Pop-up, onClick is not rendering</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1476849#M84682</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/644450"&gt;@UgurcanErkal&lt;/a&gt;&amp;nbsp; merhaba;&lt;BR /&gt;aynı sorunla karsılasıyorum. Popup içine bir html etiketi örneğin button eklemek istiyorum. Yardımcı olurmusun&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 11:39:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-pop-up-onclick-is-not-rendering/m-p/1476849#M84682</guid>
      <dc:creator>emreaktas1</dc:creator>
      <dc:date>2024-05-22T11:39:29Z</dc:date>
    </item>
  </channel>
</rss>

