Dashboards & Visualizations

How do I import an external script in advanced xml?

dlee360
Explorer

I know in simple xml, you can add a script="xx.js" in the dashboard tag, but how do I add an external script in advanced xml?

Thanks!
David

0 Karma

paramagurukarth
Builder

Inside application.js.... (http://docs.splunk.com/Documentation/Splunk/6.2.1/Module/Simplecustomizations)
After checking your current view name... you can do it using jquery
Below code is to include a css file
(You can place your js file into ../appserver/static of your application)

 switch (Splunk.util.getCurrentView()) {
       case "simple_alert_list_new":
             jQuery("<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/css/bootstrap.min.css\"/>").appendTo("head");
0 Karma

dlee360
Explorer

Thanks, but I don't have access to add to the /appserver/static directory. Maybe I'm overthinking this. I'm trying to use bootstrap modal and it works in simple xml. I just can't get it to work using advanced xml. I was thinking that maybe it was because the calling of the modal.js script. That's my best guess.
http://blogs.splunk.com/2014/02/24/using-bootstrap-modal-with-splunk-simple-xml/

0 Karma

paramagurukarth
Builder

If you don't have rights to create appserver/static directory.. you can use the bootstrap.js available inside splunk.. All the resources present inside "exposed" (ie, C:\Program Files\Splunk\share\splunk\search_mrsparkle\exposed)
are exposed in splunk as static resouces...
Url Patter to refer this is :
http://localhost:8000/en-GB/static/js/contrib/jquery/jquery.js
ie,


And you can inject the HTML code for the model using jquery or pure JavaScript by adding few line in application.js...

But, Make sure you are appending the script file after including the ...
Above is just up to my knowledge.. There may be some other options too...

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...