<?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: Having a button pass a variable into a function in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853008#M11065</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not really sure sorry.... I'm not that skilled in JS.... If I understand correctly, this is how i'm doing it...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;string = '&amp;lt;p&amp;gt;' + consentLocattr&lt;I&gt;[1] + '&amp;lt;button id='+i+' data-dojo-attach-event="onclick:delete()"&amp;gt;Delete&amp;lt;/button&amp;gt;&amp;lt;/p&amp;gt;';&lt;/I&gt;
document.getElementById("current").innerHTML = document.getElementById("current").innerHTML + string;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 10:31:02 GMT</pubDate>
    <dc:creator>HamishKingsbury1</dc:creator>
    <dc:date>2021-12-12T10:31:02Z</dc:date>
    <item>
      <title>Having a button pass a variable into a function</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853004#M11061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'm trying to do is when a list of points are added to a map, they are also added to a list which is displayed to the user. What I want to be able to do is beside each of these items is have a 'delete' button which will pass the button ID into a function. I have got all the code figured out apart from passing a unique variable into a function to delete the correct point. Below is the code I have so far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code which creates a delete button with a unique ID (basically i want that id passed into the function)&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14362301486084206 jive_text_macro" data-renderedposition="142_8_895_16" jivemacro_uid="_14362301486084206"&gt;&lt;P&gt; string = '&amp;lt;p&amp;gt;' + consentLocattr&lt;I&gt;[1] + '&amp;lt;button id='+i+' data-dojo-attach-event="onclick:delete('+i+')"&amp;gt;Delete&amp;lt;/button&amp;gt;&amp;lt;/p&amp;gt;';&lt;/I&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And here is the function (at the moment i'm just trying to get it to work)&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14362302544847944 jive_text_macro" data-renderedposition="199_8_895_88" jivemacro_uid="_14362302544847944"&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;delete: function(item){&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;alert(item);&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;},&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/PRE&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers, and sorry about the formatting, it doesn't seem to like me currently&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hamish&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Hamish Kingsbury&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 00:52:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853004#M11061</guid>
      <dc:creator>HamishKingsbury1</dc:creator>
      <dc:date>2015-07-07T00:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Having a button pass a variable into a function</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853005#M11062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hamish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; My suggestion is not to pass anything in the delete function call from onclick and in the actual delete function use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;delete: function(evt){
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.info(evt.target.id);
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:30:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853005#M11062</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T10:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Having a button pass a variable into a function</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853006#M11063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert, I tried that, changing the string to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14362331658086683 jive_text_macro" data-renderedposition="50_8_912_16" jivemacro_uid="_14362331658086683" modifiedtitle="true"&gt;&lt;P&gt;string = '&amp;lt;p&amp;gt;' + consentLocattr&lt;I&gt;[1] + '&amp;lt;button id='+i+' data-dojo-attach-event="onclick:delete()"&amp;gt;Delete&amp;lt;/button&amp;gt;&amp;lt;/p&amp;gt;';&lt;/I&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and the function to what you suggested, however nothing comes up in the console. Not even an error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 01:40:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853006#M11063</guid>
      <dc:creator>HamishKingsbury1</dc:creator>
      <dc:date>2015-07-07T01:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Having a button pass a variable into a function</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853007#M11064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hamish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; OK, &lt;SPAN class="string"&gt;data-dojo-attach-events are ONLY for items that are exiting in the template html and will not be used for items that are dynamically added via code. So when you add string var from your code are you using domConstruct to create the actual dom elements?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 18:15:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853007#M11064</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-07-07T18:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Having a button pass a variable into a function</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853008#M11065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not really sure sorry.... I'm not that skilled in JS.... If I understand correctly, this is how i'm doing it...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;string = '&amp;lt;p&amp;gt;' + consentLocattr&lt;I&gt;[1] + '&amp;lt;button id='+i+' data-dojo-attach-event="onclick:delete()"&amp;gt;Delete&amp;lt;/button&amp;gt;&amp;lt;/p&amp;gt;';&lt;/I&gt;
document.getElementById("current").innerHTML = document.getElementById("current").innerHTML + string;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:31:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853008#M11065</guid>
      <dc:creator>HamishKingsbury1</dc:creator>
      <dc:date>2021-12-12T10:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Having a button pass a variable into a function</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853009#M11066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hamish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; OK that is the problem. You need to look into dojo/dom-construct for building dom elements dynamically like you are doing especially if you wan to attach event.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 20:42:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853009#M11066</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-07-07T20:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Having a button pass a variable into a function</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853010#M11067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 21:43:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/having-a-button-pass-a-variable-into-a-function/m-p/853010#M11067</guid>
      <dc:creator>HamishKingsbury1</dc:creator>
      <dc:date>2015-07-07T21:43:57Z</dc:date>
    </item>
  </channel>
</rss>

