<?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: WAB - &amp;quot;this&amp;quot; Keyword Conflict with Button Element in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wab-quot-this-quot-keyword-conflict-with-button/m-p/1271380#M80660</link>
    <description>&lt;P&gt;Glad to help you out!&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2023 15:24:36 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2023-03-24T15:24:36Z</dc:date>
    <item>
      <title>WAB - "this" Keyword Conflict with Button Element</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wab-quot-this-quot-keyword-conflict-with-button/m-p/1271220#M80653</link>
      <description>&lt;P&gt;I created a button element with an &lt;FONT face="courier new,courier"&gt;onclick&lt;/FONT&gt; using the following method:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;domConstruct.create('button', {
  ...
  value: someValue;
  onclick: this.onBtnClick
}, someNode);&lt;/LI-CODE&gt;&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;onBtnClick&lt;/FONT&gt; method uses the value of the button element, and also calls another function:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;onBtnClick: function() {
  var someVar = this.value;
  this.someFunc();
},

someFunc: function() {
  ...
},&lt;/LI-CODE&gt;&lt;P&gt;When executing the &lt;FONT face="courier new,courier"&gt;onclick&lt;/FONT&gt;, it gives this error:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#FF0000"&gt;Uncaught TypeError: this.someFunc is not a function at HTMLButtonElement.onBtnClick&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;However, the button element's value could be correctly fetched by &lt;FONT face="courier new,courier"&gt;this.value&lt;/FONT&gt;. So it looks like in the &lt;FONT face="courier new,courier"&gt;onBtnClick&lt;/FONT&gt; method the &lt;FONT face="courier new,courier"&gt;this&lt;/FONT&gt; keyword only refers to the button element instead of the entire widget. Is there anyway to use both &lt;FONT face="courier new,courier"&gt;this.value&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;this.someFunc&lt;/FONT&gt; in &lt;FONT face="courier new,courier"&gt;onBtnClick&lt;/FONT&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 23:08:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wab-quot-this-quot-keyword-conflict-with-button/m-p/1271220#M80653</guid>
      <dc:creator>XuanKuai</dc:creator>
      <dc:date>2023-03-23T23:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: WAB - "this" Keyword Conflict with Button Element</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wab-quot-this-quot-keyword-conflict-with-button/m-p/1271301#M80658</link>
      <description>&lt;P&gt;You have to use the &lt;A href="https://dojotoolkit.org/reference-guide/1.10/dojo/_base/lang.html#hitch" rel="nofollow noreferrer" target="_blank"&gt;hitch&lt;/A&gt; function in the dojo/_base/lang module when using "this" in callback functions. Here is how I use in my code to run the function "applyEdits" when clicking on a button&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import lang from "dojo/_base/lang";

domConstruct.create(
  "div",
  {
    class: "jimu-btn " + settingName,
    style: "margin-top: 5px; margin-bottom: 5px;",
    onclick: lang.hitch(this, function (evt) {
      this.applyEdits(evt);
    })
  },
  container
);&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Mar 2023 12:42:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wab-quot-this-quot-keyword-conflict-with-button/m-p/1271301#M80658</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-03-24T12:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: WAB - "this" Keyword Conflict with Button Element</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wab-quot-this-quot-keyword-conflict-with-button/m-p/1271379#M80659</link>
      <description>&lt;P&gt;Thank you! This enables me to use the function while also using evt.target.value to access the button's value. And thank you for answering the same question on the other website!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 15:22:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wab-quot-this-quot-keyword-conflict-with-button/m-p/1271379#M80659</guid>
      <dc:creator>XuanKuai</dc:creator>
      <dc:date>2023-03-24T15:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: WAB - "this" Keyword Conflict with Button Element</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wab-quot-this-quot-keyword-conflict-with-button/m-p/1271380#M80660</link>
      <description>&lt;P&gt;Glad to help you out!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 15:24:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/wab-quot-this-quot-keyword-conflict-with-button/m-p/1271380#M80660</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-03-24T15:24:36Z</dc:date>
    </item>
  </channel>
</rss>

