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!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...