<?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: JavaScript not working when using multiple tokens in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-not-working-when-using-multiple-tokens/m-p/533180#M36311</link>
    <description>&lt;P&gt;Managed to sort it out by using more js and css.&lt;/P&gt;&lt;P&gt;In js I watch "foo_color" token and when changed, it appends class to "foo", which has either green or red color in it.&lt;/P&gt;&lt;P&gt;Shortened example in js:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var defaultTokenModel = mvc.Components.get("default");
defaultTokenModel.on("change:foo_color", function () {
   if (defaultTokenModel.get("foo_color" == "Faulty" &amp;amp;&amp;amp; !($("#foo").hasClass('faulty'))) {
     $("#foo").addClass('faulty');
   } else if ($("#foo").hasClass('faulty')) {  
      $("#foo").removeClass('faulty');
   }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Dec 2020 15:35:58 GMT</pubDate>
    <dc:creator>PavelNed</dc:creator>
    <dc:date>2020-12-15T15:35:58Z</dc:date>
    <item>
      <title>JavaScript not working when using multiple tokens</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-not-working-when-using-multiple-tokens/m-p/532336#M36216</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I am currently struggling with making JS work at dashboard. My idea is to have a line graph with some data and add another line based on button clicked. I have set of buttons in html. When clicked, it calls JS function and changes token (token_foo) value to given string, which is then used in graph search. Well, this part works just fine. Until...&lt;/P&gt;&lt;P&gt;Now let's say I would like to color these buttons based on other tokens. Once I do it, buttons get the right color, but suddenly refuse to call the JS function. The same happens when I try to display token value by &amp;lt;p&amp;gt;$foo_color$&amp;lt;/p&amp;gt;.&lt;/P&gt;&lt;P&gt;Shortened XML code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;row&amp;gt;    
&amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;input type="button" id="foo" value="Foo" style="background-color:$foo_color$"/&amp;gt;
        &amp;lt;input type="button" id="boo" value="Boo" style="background-color:$boo_color$"/&amp;gt;
       &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;event&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;condition match="'job.resultCount' == 0"&amp;gt;
              &amp;lt;set token="foo_color"&amp;gt;#00FF00&amp;lt;/set&amp;gt;
            &amp;lt;/condition&amp;gt;
            &amp;lt;condition match="'job.resultCount' &amp;amp;gt; 0"&amp;gt;
              &amp;lt;set token="foo_color"&amp;gt;#FF0000&amp;lt;/set&amp;gt;
            &amp;lt;/condition&amp;gt;
          &amp;lt;/done&amp;gt;
          &amp;lt;query&amp;gt;index="foo_index"&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$time_picker.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$time_picker.latest$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="list.drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/event&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;What am I missing?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 13:58:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-not-working-when-using-multiple-tokens/m-p/532336#M36216</guid>
      <dc:creator>PavelNed</dc:creator>
      <dc:date>2020-12-08T13:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript not working when using multiple tokens</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-not-working-when-using-multiple-tokens/m-p/533180#M36311</link>
      <description>&lt;P&gt;Managed to sort it out by using more js and css.&lt;/P&gt;&lt;P&gt;In js I watch "foo_color" token and when changed, it appends class to "foo", which has either green or red color in it.&lt;/P&gt;&lt;P&gt;Shortened example in js:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var defaultTokenModel = mvc.Components.get("default");
defaultTokenModel.on("change:foo_color", function () {
   if (defaultTokenModel.get("foo_color" == "Faulty" &amp;amp;&amp;amp; !($("#foo").hasClass('faulty'))) {
     $("#foo").addClass('faulty');
   } else if ($("#foo").hasClass('faulty')) {  
      $("#foo").removeClass('faulty');
   }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 15:35:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-not-working-when-using-multiple-tokens/m-p/533180#M36311</guid>
      <dc:creator>PavelNed</dc:creator>
      <dc:date>2020-12-15T15:35:58Z</dc:date>
    </item>
  </channel>
</rss>

