All Apps and Add-ons

How to use the value of a text box defined in a Sideview Utils HTML module in other modules?

iamniks
Explorer

Hi,

I have defined a datepicker in a Sideview Utils HTML module

<module name="HTML" >
          <param name="html"><![CDATA]

 <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
     <script>
   $$(function() {
     $$( "#datepicker" ).datepicker();
});
 </script>
 <p>Date: <input type="text" id="datepicker" name="datepicker" /></p>
    ]]></param>
  </module>

How can we access this in other Sideview Utils modules?
For example:

<module name="Search"   autoRun="True" group="Moving Label Step Average" >
     <param name="search">index=re source="*step.csv"  date=$datepicker$</param>

</module>

sideview
SplunkTrust
SplunkTrust

Well, to be honest, it would be extremely difficult because this is not the way you want to do this, at all.

Backing up, there is a DateTime module in Sideview Utils (if you don't see it then you're on the ancient LGPL version and you should update to the free 3.X version here: http://sideviewapps.com/apps/sideview-utils/)

The DateTime module is configurable to allow just dates, or dates plus times to be selected. It can also be used in pairs thus to pick both start time and end time.

If DateTime isn't your cup of tea for some reason the way you would extend a sideview XML view with custom Javascript is through a customBehavior module. This allows for a much cleaner implementation, with JS living in application.js. You can find a docs page talking about customBehaviors if you go to Tools > Other Tools, then scroll down to the bottom and click the link you see there.

CustomBehaviors can be very simple or very complex but there are a lot of examples hidden away inside Sideview Utils.

One more note - in general you want to avoid the HTML module for custom stuff like this, because when the HTML module receives a push from upstream, all the HTML inside will be thrown away and rewritten. This almost always has crippling effects on custom code like this. In this case your JS would execute again, and even when the JS is off in application.js, recreating the HTML will usually reset the state as well as sever the relationship between the HTML in the page and the JS that's trying to modify it.

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...