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!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...