The MVC class is used for working with tokens, and for accessing SplunkJS Stack views, search managers, and Simple XML visualizations.
Name | Description |
Components.get(component_id) | Returns a SplunkJS Stack view, search manager, or Simple XML visualization. |
Components.getInstance(component_id) | Returns the token model in an HTML dashboard. |
Components.registerInstance(id, component, options) | Registers a view, search manager, or token model in the Splunk registry. |
getFilter(filter_name) | Returns the filter function for the specified filter name. |
setFilter(filter_name, filterFcn) | Returns a transformed value. For details, see Transform and validate tokens. |
tokenEscape(literal_string) | Indicates that a string is a literal string. For details, see Token sytax. |
tokenSafe(token_name) | Indicates that a string is a token. For details, see Token sytax. |
This example shows how to retrieve a chart visualization in a Simple XML extension.
require([ "splunkjs/mvc", "splunkjs/mvc/simplexml/ready!" ], function(mvc) { // Retrieve the chart var chartclick = splunkjs.mvc.Components.get("mychart"); // Respond to legend clicks chartclick.on("click:legend", function(e) { // To do: respond to events console.log("Clicked legend: ", e.name2); }); // Respond to chart clicks chartclick.on("click:chart", function (e) { // To do: respond to events console.log("Clicked chart: ", e.value); }); });
This example shows how to specify a token for the value of a dropdown list.
require([ "splunkjs/mvc", "splunkjs/mvc/dropdownview", "splunkjs/mvc/simplexml/ready!" ], function(mvc, DropdownView) { new DropdownView({ id: "selIndex", value: mvc.tokenSafe("$indexName$"), el: $("#selIndex") }).render(); . . . });