Dashboards & Visualizations

Can a foo token be passed to inline javascript

adityapavan18
Contributor

is it possible to pass the foo token as an argument to inline javascript function

Tags (3)

sideview
SplunkTrust
SplunkTrust

I feel like you're asking whether the HTML module can be given an embedded <script> tag, in which a call is made, on which call is passed a $foo$ token. Do I have the spirit of your question right?

Assuming I do, it gets really confusing fast, to try and embed script into HTML modules. The HTML module will completely re-render it's contents whenever it receives a push from upstream (see the "Introduction to the advanced XML" page in Sideview Utils for an explanation of what this means).

Instead of making function calls from an HTML module though, it is much better to make a proper interface between the module system and your custom code, in the form of a CustomBehavior module. You then embed the CustomBehavior module into some appropriate point in the hierarchy, and you define the actual behavior in application.js (See the CustomBehavior docs in Sideview Utils). If you want it to do something when it receives a push, you implement onContextChange. If you want it to provide new tokens to downstream modules, you implement getModifiedContext. Those are the two most common methods overridden but there's no limit to the other weirder things you can do.

Also make sure you've read all the Sideview Utils docs and you have the latest version. Sometimes people go to the trouble of making a customBehavior to do something that can already be done using the Sideview modules.

http://sideviewapps.com/apps/sideview-utils

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...