So I'm trying to change a token when i click a button. Tried it like this: require([
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
], function ( $,mvc,TableView) {
var tokens = mvc.Components.get('default');
var sub_tok = mvc.Components.get("submitted");
$(document).on("click","#testbtn",function(){
tokens.set("btnClick", "Click");
sub_tok.set("btnClick", "Click");
});
}); And like this: require([
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
], function ( $,mvc,TableView) {
var tokens = mvc.Components.get('default');
var sub_tok = mvc.Components.get("submitted");
$("#testbtn").on("click",function(){
tokens.set("btnClick", "Click");
sub_tok.set("btnClick", "Click");
});
}); But its not working. When i try the code in jsFiddle it works as intended. (leaving out the splunk stuff) It's just a jQuery click event, so I don't know what I'm doing wrong. Further more when I try the whole think with a slider, it works. require([
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
], function ( $,mvc,TableView) {
var tokens = mvc.Components.get('default');
var sub_tok = mvc.Components.get("submitted");
$("#slider-range").on("input change", function () {
tokens.set("slider_value", $(this).val());
sub_tok.set("slider_value", $(this).val());
});
}); Here ist the xml code: <dashboard script="testscript.js" theme="dark">
<label></label>
<fieldset submitButton="false">
<html>
<label>Slider</label>
<input type="range" id="slider_input" value="10" min="0" max="20" step="1"/>
<button id="testbtn">ghfhfhfhfh</button>
</html>
</fieldset>
<row>
<panel>
<title>$slider_value$____$btnClick$</title>
<table>
<search>
<query>|makeresults | eval slider_value=$slider_value$</query>
<earliest>-1h@h</earliest>
<latest>now</latest>
</search>
<option name="refresh.display">progressbar</option>
</table>
</panel>
</row>
</dashboard> I there is a simple solution to this and thanks in advance.
... View more