<?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 Token update disables JS function for button? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Token-update-disables-JS-function-for-button/m-p/394662#M25821</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;

&lt;P&gt;i have some buttons on my page which i want label dynamically depending on a token the user picks from a dropdown menu.&lt;BR /&gt;
The corresponding labels are saved in a lookup file which i access through javascript. Upon clicking on the buttons a search should be started to write in a kv store.&lt;/P&gt;

&lt;P&gt;To this point, everything works just fine.&lt;BR /&gt;
As soon as i change the token from the dropdown menu, the buttons stop working until i refresh the whole page.&lt;BR /&gt;
Everything in my js file but the button clicking is still working after the changing of the token.&lt;/P&gt;

&lt;P&gt;Here is the code for the buttons I'm using (i also tried "document.getElementById("quickChange0").addEventListener("click"..." but that did not solve the problem) :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$('#quickChange0').click(function () {
            var selected = tokens.get("selected");          
            var doQuickChange1 = "really long search";              

            console.log(doQuickChange1);
            service.search(doQuickChange1);
            setTimeout(function(){location.reload()},1000);             
        });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does anyone know why this is or has an idea how to do this in a different way?&lt;BR /&gt;
Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Wed, 09 Jan 2019 16:03:11 GMT</pubDate>
    <dc:creator>hmaschki</dc:creator>
    <dc:date>2019-01-09T16:03:11Z</dc:date>
    <item>
      <title>Token update disables JS function for button?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Token-update-disables-JS-function-for-button/m-p/394662#M25821</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;

&lt;P&gt;i have some buttons on my page which i want label dynamically depending on a token the user picks from a dropdown menu.&lt;BR /&gt;
The corresponding labels are saved in a lookup file which i access through javascript. Upon clicking on the buttons a search should be started to write in a kv store.&lt;/P&gt;

&lt;P&gt;To this point, everything works just fine.&lt;BR /&gt;
As soon as i change the token from the dropdown menu, the buttons stop working until i refresh the whole page.&lt;BR /&gt;
Everything in my js file but the button clicking is still working after the changing of the token.&lt;/P&gt;

&lt;P&gt;Here is the code for the buttons I'm using (i also tried "document.getElementById("quickChange0").addEventListener("click"..." but that did not solve the problem) :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$('#quickChange0').click(function () {
            var selected = tokens.get("selected");          
            var doQuickChange1 = "really long search";              

            console.log(doQuickChange1);
            service.search(doQuickChange1);
            setTimeout(function(){location.reload()},1000);             
        });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does anyone know why this is or has an idea how to do this in a different way?&lt;BR /&gt;
Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 16:03:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Token-update-disables-JS-function-for-button/m-p/394662#M25821</guid>
      <dc:creator>hmaschki</dc:creator>
      <dc:date>2019-01-09T16:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Token update disables JS function for button?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Token-update-disables-JS-function-for-button/m-p/394663#M25822</link>
      <description>&lt;P&gt;The the problem was, that i defined my buttons inside the xml of my dashboard.&lt;BR /&gt;
Everything is working fine when i use JS to define the buttons.&lt;/P&gt;

&lt;P&gt;Problably there is a problem with the way splunk handels IDs when reloading the page upon changing tokens.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jan 2019 14:58:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Token-update-disables-JS-function-for-button/m-p/394663#M25822</guid>
      <dc:creator>hmaschki</dc:creator>
      <dc:date>2019-01-15T14:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Token update disables JS function for button?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Token-update-disables-JS-function-for-button/m-p/394664#M25823</link>
      <description>&lt;P&gt;@hmaschki, even if you have created a button in Simple XML code, it should work with Simple XML JS extension where you handle click event in JavaScript. Refer to @jconger 's blog: &lt;A href="https://www.splunk.com/blog/2016/09/21/using-html5-input-types-on-splunk-forms.html"&gt;https://www.splunk.com/blog/2016/09/21/using-html5-input-types-on-splunk-forms.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Instead of &lt;CODE&gt;$('#quickChange0').click(function ()&lt;/CODE&gt; can you try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$(document).on('click','#quickChange0',function(){
      console.log('quickChange0 Clicked');
       ...
       ...

});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Jan 2019 17:34:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Token-update-disables-JS-function-for-button/m-p/394664#M25823</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-15T17:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Token update disables JS function for button?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Token-update-disables-JS-function-for-button/m-p/394665#M25824</link>
      <description>&lt;P&gt;That works aswell! So you can either use .on('click'...) or define the buttons in js. I would prefer your solution. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 07:32:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Token-update-disables-JS-function-for-button/m-p/394665#M25824</guid>
      <dc:creator>hmaschki</dc:creator>
      <dc:date>2019-01-16T07:32:22Z</dc:date>
    </item>
  </channel>
</rss>

