<?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 code is disappeared when the dashboard is loaded in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473728#M45809</link>
    <description>&lt;P&gt;Well, Not sure but as per my understanding and experience, JavaScript extension (JavaScript file)  is executing with the internal (Splunk's internal dashboard supported JavaScript files) dashboard JavaScript executes. We are injecting our code into dashboard using JavaScript extension So possibilities of code impact overriding is there. So here, I have used a trick and used &lt;CODE&gt;$(document).ready(function() {..}&lt;/CODE&gt; and &lt;CODE&gt;setTimeout&lt;/CODE&gt; to execute my code. &lt;/P&gt;

&lt;P&gt;You can decrease the timer from &lt;CODE&gt;2000&lt;/CODE&gt; to &lt;CODE&gt;1000&lt;/CODE&gt; or less to minimize delay. &lt;/P&gt;

&lt;P&gt;If you got your solution then can you please upvote and accept this answer to close this question?&lt;/P&gt;</description>
    <pubDate>Tue, 31 Dec 2019 16:42:45 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2019-12-31T16:42:45Z</dc:date>
    <item>
      <title>JavaScript code is disappeared when the dashboard is loaded</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473721#M45802</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a dashboard  html tags inside.&lt;BR /&gt;
My goal is to use custom JavaScript which replace the innerHTML text of on of my span elements.&lt;BR /&gt;
When debugging the JS code, I can see that the value is replaced as I expected but after clicking on resume, it goes back to the old value like nothing happened.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
     'jquery',
     'splunkjs/mvc',
     'splunkjs/mvc/simplexml/ready!'
 ], function($, mvc,) {
         document.getElementById("myspan").innerHTML = "GOOGLE".link("www.google.com");
 });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does anyone know what's wrong?&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 15:45:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473721#M45802</guid>
      <dc:creator>shayhibah</dc:creator>
      <dc:date>2019-12-31T15:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript code is disappeared when the dashboard is loaded</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473722#M45803</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;It is working fine&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="custom.js"&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;p&amp;gt;
          &amp;lt;span id="myspan"&amp;gt;test&amp;lt;/span&amp;gt;
        &amp;lt;/p&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;js:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
      'jquery',
      'splunkjs/mvc',
      'splunkjs/mvc/simplexml/ready!'
  ], function($, mvc,) {
          document.getElementById("myspan").innerHTML = "GOOGLE".link("http://www.google.com");
  });
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Dec 2019 16:02:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473722#M45803</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-12-31T16:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript code is disappeared when the dashboard is loaded</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473723#M45804</link>
      <description>&lt;P&gt;@vnravikumar &lt;/P&gt;

&lt;P&gt;Thanks for your response.&lt;BR /&gt;
For some reason, I am able to see that the page is rendered and my "GOOGLE" is disappeared.&lt;/P&gt;

&lt;P&gt;Do you know what can cause this behavior?&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 16:05:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473723#M45804</guid>
      <dc:creator>shayhibah</dc:creator>
      <dc:date>2019-12-31T16:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript code is disappeared when the dashboard is loaded</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473724#M45805</link>
      <description>&lt;P&gt;Can you please check by clearing your browser cache&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 16:11:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473724#M45805</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-12-31T16:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript code is disappeared when the dashboard is loaded</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473725#M45806</link>
      <description>&lt;P&gt;@shayhibah &lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/simplexml/ready!'
], function($, mvc,) {
    $(document).ready(function() { 
        var myVar = setTimeout(function(){ document.getElementById("myspan").innerHTML = "GOOGLE".link("www.google.com"); 
        }, 2000);
    });
 });
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Dec 2019 16:17:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473725#M45806</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-12-31T16:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript code is disappeared when the dashboard is loaded</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473726#M45807</link>
      <description>&lt;P&gt;@vnravikumar &lt;BR /&gt;
I already did it.&lt;BR /&gt;
I noticed that it happens only when my html code inside the dashboard XML contains many other div and span tags .&lt;/P&gt;

&lt;P&gt;For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel id="details_panel"&amp;gt;
      &amp;lt;title&amp;gt;General Information&amp;lt;/title&amp;gt;
      &amp;lt;html&amp;gt;
         &amp;lt;div&amp;gt;
          &amp;lt;span&amp;gt;
            &amp;lt;b&amp;gt;ID: &amp;lt;/b&amp;gt;$technique_id$&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
         &amp;lt;div&amp;gt;
          &amp;lt;span&amp;gt;
            &amp;lt;b&amp;gt;Tactics: &amp;lt;/b&amp;gt;$technique_tactics$&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
         &amp;lt;div&amp;gt;
          &amp;lt;span&amp;gt;
            &amp;lt;b&amp;gt;Platform: &amp;lt;/b&amp;gt;$technique_platform$&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
         &amp;lt;div&amp;gt;
          &amp;lt;span&amp;gt;
            &amp;lt;b&amp;gt;Permissions Required: &amp;lt;/b&amp;gt;$technique_permissions_required$&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
         &amp;lt;div&amp;gt;
          &amp;lt;span&amp;gt;
            &amp;lt;b&amp;gt;Effective Permissions: &amp;lt;/b&amp;gt;$technique_effective_permissions$&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
         &amp;lt;div&amp;gt;
          &amp;lt;span&amp;gt;
            &amp;lt;b&amp;gt;Data Sources: &amp;lt;/b&amp;gt;$technique_data_sources$&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
         &amp;lt;div id="myspan"/&amp;gt;
         &amp;lt;div&amp;gt;
          &amp;lt;span&amp;gt;
            &amp;lt;b&amp;gt;Contributors: &amp;lt;/b&amp;gt;$technique_contributors$&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
         &amp;lt;div&amp;gt;
          &amp;lt;span&amp;gt;
            &amp;lt;b&amp;gt;Requires Network: &amp;lt;/b&amp;gt;$technique_requires_network$&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
         &amp;lt;div&amp;gt;
          &amp;lt;span&amp;gt;
            &amp;lt;b&amp;gt;Version: &amp;lt;/b&amp;gt;$technique_version$&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
       &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once the page is loaded, it seems that "myspan" is empty although that I am able to see its value during debugging process.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 16:19:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473726#M45807</guid>
      <dc:creator>shayhibah</dc:creator>
      <dc:date>2019-12-31T16:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript code is disappeared when the dashboard is loaded</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473727#M45808</link>
      <description>&lt;P&gt;@kamlesh_vaghela &lt;BR /&gt;
It works!&lt;/P&gt;

&lt;P&gt;Can you please explain it?&lt;BR /&gt;
And in addition, how can I set the value as fast as possible? there is a small delay..&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 16:25:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473727#M45808</guid>
      <dc:creator>shayhibah</dc:creator>
      <dc:date>2019-12-31T16:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript code is disappeared when the dashboard is loaded</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473728#M45809</link>
      <description>&lt;P&gt;Well, Not sure but as per my understanding and experience, JavaScript extension (JavaScript file)  is executing with the internal (Splunk's internal dashboard supported JavaScript files) dashboard JavaScript executes. We are injecting our code into dashboard using JavaScript extension So possibilities of code impact overriding is there. So here, I have used a trick and used &lt;CODE&gt;$(document).ready(function() {..}&lt;/CODE&gt; and &lt;CODE&gt;setTimeout&lt;/CODE&gt; to execute my code. &lt;/P&gt;

&lt;P&gt;You can decrease the timer from &lt;CODE&gt;2000&lt;/CODE&gt; to &lt;CODE&gt;1000&lt;/CODE&gt; or less to minimize delay. &lt;/P&gt;

&lt;P&gt;If you got your solution then can you please upvote and accept this answer to close this question?&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 16:42:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/JavaScript-code-is-disappeared-when-the-dashboard-is-loaded/m-p/473728#M45809</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-12-31T16:42:45Z</dc:date>
    </item>
  </channel>
</rss>

