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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...