Hi @catta99, You probably want to start with buttons disabled and then enabled them when the dashboard's async searches are done. You can use SplunkJS to attach search:done event handlers to your se...
See more...
Hi @catta99, You probably want to start with buttons disabled and then enabled them when the dashboard's async searches are done. You can use SplunkJS to attach search:done event handlers to your searches (see below). A complex dashboard (multiple searches, multiple buttons, etc.) may require a more complex solution. You can find more information in the SplunkJS documentation or more generally, in your favorite web development resources (or AI stack, if you use one). <!-- button_test.xml -->
<dashboard version="1.1" theme="light" script="button_test.js">
<label>button_test</label>
<search id="search1">
<query>| stats count</query>
<earliest>-24h</earliest>
<latest>now</latest>
</search>
<row>
<panel>
<html>
<!-- assign a value to the disabled attribute to pass SplunkWeb's Simple XML validation -->
<button id="button1" disabled="disabled">Button 1</button>
</html>
</panel>
</row>
</dashboard> // button_test.js
require([
"jquery",
"splunkjs/mvc",
"splunkjs/mvc/simplexml/ready!"
], function($, mvc) {
search1 = splunkjs.mvc.Components.get("search1");
search1.on("search:done", function(properties) {
$("#button1").prop("disabled", false);
});
$("#button1").on("click", function() {
alert("Button 1 clicked.");
});
});