<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Learning to include jquery in simple xml in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/531878#M36155</link>
    <description>&lt;P&gt;I tried to get a function to run on page load, making use of the code you have shown:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$(document).ready(function() {
	console.log("page opened");
});&lt;/LI-CODE&gt;&lt;P&gt;I just could not get that event to trigger on page load (I did a bump and refreshed the page). I finally tried:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$(function(){ console.log("page opened"); });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;and this worked. No idea why,&amp;nbsp; in my mind these two are equivalent.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Dec 2020 14:35:27 GMT</pubDate>
    <dc:creator>BernardEAI</dc:creator>
    <dc:date>2020-12-03T14:35:27Z</dc:date>
    <item>
      <title>Learning to include jquery in simple xml</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137281#M8211</link>
      <description>&lt;P&gt;Hi to all, i'm just learning to usi a little of custom jquery in splunk simple dashboard.&lt;BR /&gt;
I have this at begining of my xml:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="script.js" stylesheet="dark.css"&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in script.js i have this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
     'jquery',
     'splunkjs/mvc/simplexml/ready!'
 ], function($) {
    $(document).ready(function() {
        $( "#row1" ).addClass( "red" );
    }); 
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;just a stupid code to see if it's works, but it does not.&lt;/P&gt;

&lt;P&gt;Of cource in .css i have the class red. Even if i run in the chrome console:&lt;CODE&gt;$( "#row1" ).addClass( "red" );&lt;/CODE&gt; nothing happens.&lt;/P&gt;

&lt;P&gt;Could you please help me?&lt;/P&gt;

&lt;P&gt;Thanks and regards.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 17:22:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137281#M8211</guid>
      <dc:creator>maurelio79</dc:creator>
      <dc:date>2015-06-05T17:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Learning to include jquery in simple xml</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137282#M8212</link>
      <description>&lt;P&gt;Your sample code does work, so my guess is that your script isn't being seen by Splunk and isn't loading.  View the page source to see if Splunk was able to find it and load it into your dashboard.&lt;/P&gt;

&lt;P&gt;The CSS should appear in the &lt;CODE&gt;head&lt;/CODE&gt; tag:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;head&amp;gt;
    ...
    &amp;lt;link rel="stylesheet" type="text/css" media="all" href="/en-US/static/@264376:0/app/search/dark.css" /&amp;gt;
    ...
&amp;lt;/head&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The JavaScript should be at the bottom of the page just before the closing of the &lt;CODE&gt;body&lt;/CODE&gt; tag:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;script src="/en-US/static/@264376:0/app/search/script.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Usually in order to get my new scripts and css files to populate in a dashboard I need to restart Splunk.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 19:39:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137282#M8212</guid>
      <dc:creator>justinatpnnl</dc:creator>
      <dc:date>2015-06-05T19:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Learning to include jquery in simple xml</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137283#M8213</link>
      <description>&lt;P&gt;As  @justinatpnnl pointed out, your Javascript is probably not included in the web page because the Splunk server has not yet noticed your new Javascript file.&lt;/P&gt;

&lt;P&gt;To make a new Javascript file available without a full server restart:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SPLUNK_HOME/bin/splunk restartss
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To force a reload of a changed Javascript file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;http(s)://localhost:8000/en-US/_bump
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and click the button there to increment the version number.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jun 2015 07:01:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137283#M8213</guid>
      <dc:creator>kurdbahr</dc:creator>
      <dc:date>2015-06-06T07:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Learning to include jquery in simple xml</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137284#M8214</link>
      <description>&lt;P&gt;Thanks to all. It works, but it seems that i need a splunkweb restart every time i modify a css or js, is it normal?&lt;BR /&gt;
Thanks and regards&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jun 2015 14:37:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137284#M8214</guid>
      <dc:creator>maurelio79</dc:creator>
      <dc:date>2015-06-06T14:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Learning to include jquery in simple xml</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137285#M8215</link>
      <description>&lt;P&gt;No, a restart isn't necessary every time.  If you use the link @kurdbahr provided in the second part of his answer, it creates a new cache for JavaScript and CSS files and then you can just refresh the page. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&lt;A href="http://your_splunk_server/en-US/_bump" target="test_blank"&gt;http://your_splunk_server/en-US/_bump&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Jun 2015 15:30:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137285#M8215</guid>
      <dc:creator>justinatpnnl</dc:creator>
      <dc:date>2015-06-06T15:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Learning to include jquery in simple xml</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137286#M8216</link>
      <description>&lt;P&gt;&lt;A href="https://your_splunk_server/refresh/debug"&gt;https://your_splunk_server/refresh/debug&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 02 May 2020 07:24:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137286#M8216</guid>
      <dc:creator>renjujacob88</dc:creator>
      <dc:date>2020-05-02T07:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Learning to include jquery in simple xml</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137287#M8217</link>
      <description>&lt;P&gt;@renjujacob88 it is actually &lt;CODE&gt;&lt;A href="http://&amp;lt;splunkURLPort&amp;gt;/en-US/debug/refresh" target="test_blank"&gt;http://&amp;lt;splunkURLPort&amp;gt;/en-US/debug/refresh&lt;/A&gt;&lt;/CODE&gt;. For Development or Non-prod instances, &lt;CODE&gt;_bump&lt;/CODE&gt;, &lt;CODE&gt;debug refresh&lt;/CODE&gt; or &lt;CODE&gt;Development mode&lt;/CODE&gt; settings are recommended.&lt;/P&gt;

&lt;P&gt;Following is the URL to turn on Development Mode settings with no caching: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/AdvancedDev/CustomVizTutorial#Development_mode_settings"&gt;https://docs.splunk.com/Documentation/Splunk/latest/AdvancedDev/CustomVizTutorial#Development_mode_settings&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 05:36:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/137287#M8217</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-05-05T05:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Learning to include jquery in simple xml</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/531878#M36155</link>
      <description>&lt;P&gt;I tried to get a function to run on page load, making use of the code you have shown:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$(document).ready(function() {
	console.log("page opened");
});&lt;/LI-CODE&gt;&lt;P&gt;I just could not get that event to trigger on page load (I did a bump and refreshed the page). I finally tried:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$(function(){ console.log("page opened"); });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;and this worked. No idea why,&amp;nbsp; in my mind these two are equivalent.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 14:35:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Learning-to-include-jquery-in-simple-xml/m-p/531878#M36155</guid>
      <dc:creator>BernardEAI</dc:creator>
      <dc:date>2020-12-03T14:35:27Z</dc:date>
    </item>
  </channel>
</rss>

