All Apps and Add-ons

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

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>

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