<?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 add button with click event on popupTemplate in ACGIS JavaScript in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-button-with-click-event-on/m-p/1369391#M83328</link>
    <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check out &lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-addeventlistener-to-a-button-in-popup/td-p/1165242" target="_self"&gt;this post&lt;/A&gt; as it discusses about adding button to popupTemplate. I have updated the app to work with 4.28:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/KKENPpZ?editors=1000" target="_blank"&gt;https://codepen.io/U_B_U/pen/KKENPpZ?editors=1000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jan 2024 04:07:51 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2024-01-12T04:07:51Z</dc:date>
    <item>
      <title>How to add button with click event on popupTemplate in ACGIS JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-button-with-click-event-on/m-p/1369342#M83326</link>
      <description>&lt;P&gt;I meet a problem when trying to add button on popupTemplate in ARCGIS JavaScript;My environment is node.js, and the version of ARCGIS JavaScript is 4.28.&lt;BR /&gt;The code snippet is as following:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;const popupTemplate = {&lt;BR /&gt;&amp;nbsp;title: "{Name}",&lt;BR /&gt;&amp;nbsp;content: "{Description}"&lt;BR /&gt;}&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;var graphicID = "testing_1";&lt;BR /&gt;const buttonHTML = `&amp;lt;button class="btn btn-danger" onclick="DeleteSelectedDiagram('${graphicID}')"&amp;gt;Delete the Diagram&amp;lt;/button&amp;gt;`;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;graphic = new Graphic({&lt;BR /&gt;&amp;nbsp;geometry: new geometry.Polygon({&lt;BR /&gt;&amp;nbsp;rings: coordinates,&lt;BR /&gt;&amp;nbsp;spatialReference: {&lt;BR /&gt;&amp;nbsp;wkid: 3826&lt;BR /&gt;},&lt;BR /&gt;&amp;nbsp;id:"testing_1"&lt;BR /&gt;}),&lt;BR /&gt;symbol: {&lt;BR /&gt;&amp;nbsp; type: "simple-fill",&lt;BR /&gt;&amp;nbsp; color: [255, 0, 0, 0.3], // Red color with 0.3 opacity&lt;BR /&gt;&amp;nbsp; outline: {&lt;BR /&gt;&amp;nbsp; &amp;nbsp;color: [255, 0, 0], // Red color&lt;BR /&gt;&amp;nbsp; &amp;nbsp;width: 1&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;},&lt;BR /&gt;attributes: {&lt;BR /&gt;&amp;nbsp;Name: "Diagram Infos",&lt;BR /&gt;&amp;nbsp;Description: buttonHTML&lt;BR /&gt;&amp;nbsp;},&lt;BR /&gt;popupTemplate: popupTemplate&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;However, it is not working,the css style of button is disappear and popupTemplate only show the words "Delete the Diagram".&lt;BR /&gt;Is there any method to add button with click event to popupTemplate? any instruction is highly appreciated, thanks a lot.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 01:27:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-button-with-click-event-on/m-p/1369342#M83326</guid>
      <dc:creator>AbramhumHsu</dc:creator>
      <dc:date>2024-01-12T01:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to add button with click event on popupTemplate in ACGIS JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-button-with-click-event-on/m-p/1369391#M83328</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check out &lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-addeventlistener-to-a-button-in-popup/td-p/1165242" target="_self"&gt;this post&lt;/A&gt; as it discusses about adding button to popupTemplate. I have updated the app to work with 4.28:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/KKENPpZ?editors=1000" target="_blank"&gt;https://codepen.io/U_B_U/pen/KKENPpZ?editors=1000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 04:07:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-button-with-click-event-on/m-p/1369391#M83328</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2024-01-12T04:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to add button with click event on popupTemplate in ACGIS JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-button-with-click-event-on/m-p/1369409#M83329</link>
      <description>&lt;P&gt;Thanks for your reply, and I have some messing on the code snippet that need to confirm.&lt;BR /&gt;The first is what is the&amp;nbsp; type: "custom" and creator use for, And the second is the following, this will cause&lt;BR /&gt;invoking popup automatically each time:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;reactive.watch(&lt;BR /&gt;&amp;nbsp; () =&amp;gt; [...view.graphics.toArray()],&lt;BR /&gt;&amp;nbsp; (graphics) =&amp;gt; {&lt;BR /&gt;&amp;nbsp; if (graphics.includes(pointGraphic)) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;view.popup.open({&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; features: [pointGraphic]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;I see another code snippet like this:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;BR /&gt;view.popup.on("trigger-action", function(evt){&lt;BR /&gt;if(evt.action.id === "actionA"){&lt;BR /&gt;doSomething();&lt;BR /&gt;}&lt;BR /&gt;else if(evt.action.id === "actionB"){&lt;BR /&gt;doSomethingElse();&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;what is their difference, and why using features: [pointGraphic], thanks a lot.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 07:36:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-button-with-click-event-on/m-p/1369409#M83329</guid>
      <dc:creator>AbramhumHsu</dc:creator>
      <dc:date>2024-01-12T07:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to add button with click event on popupTemplate in ACGIS JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-button-with-click-event-on/m-p/1369616#M83334</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can create different elements to be displayed in &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content" target="_self"&gt;popupTemplate's content.&lt;/A&gt; You can learn more about custom content from &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-popup-content-CustomContent.html" target="_self"&gt;here&lt;/A&gt;. In this case we are creating a custom content to host the HTML button.&lt;/P&gt;&lt;P&gt;Trigger action is different from opening the popup. &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event-trigger-action" target="_self"&gt;Trigger action&lt;/A&gt; is an event that fires in response to user clicks an action. &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/popup-custom-action/" target="_self"&gt;This sample&lt;/A&gt; shows how to create custom actions for your popupTemplate. The action buttons are displayed like so in the popup.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-01-12 at 8.03.56 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91444i5B6320A68849B1BE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2024-01-12 at 8.03.56 AM.png" alt="Screenshot 2024-01-12 at 8.03.56 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The codepen was using deprecated method view.popup.open. I have updated the codepen to use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#openPopup" target="_self"&gt;MapView.openPopup&lt;/A&gt; method. We are passing the features parameter to the openPopup method so that the popup displays the popupTemplate associated with the graphics. Please take a look at the links I included in this response to learn about different parts of working with popup.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 16:06:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-add-button-with-click-event-on/m-p/1369616#M83334</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2024-01-12T16:06:03Z</dc:date>
    </item>
  </channel>
</rss>

