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!

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 ...