Hi @catta99, In your JavaScript source, you can use jQuery selectors to attach a click event handler to an object. In this example, I define a button with id="button1" in button_test.xml and attach...
See more...
Hi @catta99, In your JavaScript source, you can use jQuery selectors to attach a click event handler to an object. In this example, I define a button with id="button1" in button_test.xml and attach a click event handler in button_test.js: <!-- button_test.xml -->
<dashboard version="1.1" theme="light" script="button_test.js">
<label>button_test</label>
<row>
<panel>
<html>
<button id="button1">Button 1</button>
</html>
</panel>
</row>
</dashboard> // button_test.js
require([
"jquery",
"splunkjs/mvc",
"splunkjs/mvc/simplexml/ready!"
], function($, mvc) {
$("#button1").on("click", function() {
alert("Button 1 clicked.");
});
}); When button1 is clicked, the browser displays a dialog box with the message "Button 1 clicked." SplunkJS is documented at https://dev.splunk.com/enterprise/docs/developapps/visualizedata/usewebframework/, where you can find example JavaScript templates. RequireJS is documented at https://requirejs.org/docs/api.html#jsfiles, but its use is limited to the require([...], function(...) {}); shown above. jQuery selectors are documented at https://api.jquery.com/category/selectors/. The jQuery click event is documented at https://api.jquery.com/click/.