Splunk Search

include jquery into setup.xml

Nicholas_Key
Splunk Employee
Splunk Employee

Is there a way to include jquery into setup.xml?

A simple example would be to show an alert box that says "Hello World"

Tags (1)
1 Solution

Justin_Grant
Contributor

You can include an application.js file in your appserver/static directory, and it will be loaded into your setup.xml page. applicaiton.js can, in turn, load whatever other scripts it wants.

I believe that jquery is already part of Splunk, so you won't need to explicitly add jQuery yourself.

Note that application.js is loaded pretty late in the page display cycle, so the user will see the page before your script is loaded.

View solution in original post

LukeMurphey
Champion

You can also include JavaScript directory in the setup page directly using a CDATA block inside of a text node. This is useful when you have JavaScript that you want to only execute on the setup page (otherwise, you'll need to check the URL to determine if the current page is the setup page).

Consider the following that open the jQueryUI date picker dialog when the input block is clicked:

      <text>
      <![CDATA[
      <script>
          $(function() {
              $( "#datepicker" ).datepicker();
          });
      </script>

      <div class="demo">
          <p>Date: <input type="text" id="datepicker"></p>
      </div>
      ]]>
      </text>

Justin_Grant
Contributor

You can include an application.js file in your appserver/static directory, and it will be loaded into your setup.xml page. applicaiton.js can, in turn, load whatever other scripts it wants.

I believe that jquery is already part of Splunk, so you won't need to explicitly add jQuery yourself.

Note that application.js is loaded pretty late in the page display cycle, so the user will see the page before your script is loaded.

Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

Splunk is officially part of Cisco

Revolutionizing how our customers build resilience across their entire digital footprint.   Splunk ...

Splunk APM & RUM | Planned Maintenance March 26 - March 28, 2024

There will be planned maintenance for Splunk APM and RUM between March 26, 2024 and March 28, 2024 as ...