Created
September 7, 2014 21:58
-
-
Save hobbes3/f0c6df366a1454bf3a52 to your computer and use it in GitHub Desktop.
checkbox input on or off
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require([ | |
'jquery', | |
'underscore', | |
'splunkjs/mvc', | |
'splunkjs/mvc/simplexml/ready!' | |
], function( | |
$, | |
_, | |
mvc | |
) { | |
function submit_and_update_url() { | |
submitted_tokens.set(unsubmitted_tokens.toJSON()); | |
mvc.Components.get('url').saveOnlyWithPrefix('form\\.', unsubmitted_tokens.toJSON(), { | |
replaceState: false | |
}); | |
} | |
var unsubmitted_tokens = mvc.Components.get('default'); | |
var submitted_tokens = mvc.Components.get('submitted'); | |
$("#field1").hide(); // selected_system_name | |
// A single checkbox | |
var nfl_only = mvc.Components.getInstance("field4"); | |
nfl_only.on("change", function() { | |
// Used like this: | tstats count from datamodel=nfl where host=* $nfl_lookup_string$ | |
// If checked | |
if(this.val().length > 0) { | |
unsubmitted_tokens.set('nfl_lookup_string', '[| inputlookup nfl_host_list | rename SystemName as all.SystemName]'); | |
} | |
// If unchecked | |
else { | |
unsubmitted_tokens.set('nfl_lookup_string', ''); | |
} | |
// Only need to listen on master since all 3 charts depends on SystemName | |
var master_search_id = mvc.Components.get("master").settings.get("managerid"); | |
var master_search = mvc.Components.getInstance(master_search_id); | |
var after_initial = false; | |
master_search.on("search:start", function(properties) { | |
if(after_initial) { | |
unsubmitted_tokens.unset("form.selected_system_name"); | |
submit_and_update_url(); | |
} | |
after_initial = true; | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment