Alerting

How can i stop my Javascript running when i load my dashboard?

robertlynch2020
Motivator

Hi

I have a simple dashboard that is running the javascript on a load of the page.

The idea is I have a button that will do an action when I press the button.

But the javascript is running when I load the page, the button does work when you press it but the issue is it is now pressed twice not once.

Any help would be great, cheers.

 

 

<dashboard script="run_command_from_button.js">
 
  <label>Sync Configuration</label>
  <row>
    <panel >

      <title>The Below button will sync any changes from the Search head to the indexers, this can take 2 minutes to full sync</title>
      <html>
        <div>
          <input id="btn-submit" type="button" class="btn btn-primary" value="Click to Sync"/>
        </div>
      </html>
     
    </panel>
  </row>
</dashboard>

 

 

The javascript

 

 

require([
   "jquery",
   "splunkjs/mvc/searchmanager",
   "splunkjs/mvc/simplexml/ready!"
 ], function(
     $,
     SearchManager
 ) {
    

var mysearch = new SearchManager({
         id: "mysearch",
         autostart: "false",
         search: "| runshellscript  Test_runshellscript.sh 1 1 1 1 1 1 1 1" 
     });
	
     $("#btn-submit").on("click", function (){
         var ok = confirm("Push New Configuration out ot the Indexers?");
         if ( ok==true ){
             mysearch.startSearch();
         } else {
             alert('New Conf Not Pushed');
         }
     });
	
});

 

 

 

 

 

 

 

 

Labels (1)
Tags (1)
0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...