Dashboards & Visualizations

Documentation on implementing a function triggered by change of a token's value?

chrisdopuch
Path Finder

Hello,

I am trying to implement a function which triggers by the change of a token's value. Splunk's framework has a method for this, as documented here: http://dev.splunk.com/view/SP-CAAAEW4

Unfortunately, they documentation is very sparse and the example they give only confuses me further. The function which fires on a token change is supposed to accept the arguments ( model, value, options ). In the example, the model that they pass isn't defined anywhere on the page. When I tried putting in a model that I thought was relevant (a search manager which relies on the token) the page threw the error "Uncaught TypeError: Cannot read property 'query' of undefined ". Also, the second argument seems likely to throw another undefined error, since no variable with the same name as the token has been declared.

Moreover, the documentation doesn't specify any of the "options" that can be passed in as a third argument.

Can anyone point me to some better documentation, or clarify this for me with a better example?

Thank you!

1 Solution

aelliott
Motivator

This function will give you model,value, and options to use on token change(if you need to).
You do not pass something literally through this.

  defaultTokenModel.on("change:tokenName", function(model, value, options) {
       //now I can use the objects "model", "value", and "options" if i need to use these within my fuctionality
    });

View solution in original post

dfoster_splunk
Splunk Employee
Splunk Employee

The "model" parameter refers to the token model on which the on() function was invoked. You probably don't care about it.

The "value" parameter refers to the new value of the token.

The "options" parameter gives more information about how the token was changed that you probably don't care about. See the Backbone documentation for the on() call if you want details.

aelliott
Motivator

This function will give you model,value, and options to use on token change(if you need to).
You do not pass something literally through this.

  defaultTokenModel.on("change:tokenName", function(model, value, options) {
       //now I can use the objects "model", "value", and "options" if i need to use these within my fuctionality
    });
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...

Customer success is front and center at .conf25

Hi Splunkers, If you are not able to be at .conf25 in person, you can still learn about all the latest news ...

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...