<?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 How to work with javascript in splunk in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-work-with-javascript-in-splunk/m-p/155144#M9483</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am working with simple xml and i want to hide some html line using javascript.&lt;BR /&gt;
I have a simple java script file how to make it work on splunk.&lt;BR /&gt;
I am not that much into javascript.&lt;BR /&gt;
do we need to add this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   require([    
    "splunkjs/ready!",    
    "splunkjs/mvc/simplexml/ready!"    
], function(
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Simple javascript code is like this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script&amp;gt;
 $(document).ready(function() {

    $('.faq_question').click(function() {

        if ($(this).parent().is('.open')){
            $(this).closest('.faq').find('.faq_answer_container').animate({'height':'0'},500);
            $(this).closest('.faq').removeClass('open');

            }else{
                var newHeight =$(this).closest('.faq').find('.faq_answer').height() +'px';
                $(this).closest('.faq').find('.faq_answer_container').animate({'height':newHeight},500);
                $(this).closest('.faq').addClass('open');
            }

    });

});
&amp;lt;/script&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sorry if this question sounds silly.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Aug 2015 10:40:38 GMT</pubDate>
    <dc:creator>ektasiwani</dc:creator>
    <dc:date>2015-08-05T10:40:38Z</dc:date>
    <item>
      <title>How to work with javascript in splunk</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-work-with-javascript-in-splunk/m-p/155144#M9483</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am working with simple xml and i want to hide some html line using javascript.&lt;BR /&gt;
I have a simple java script file how to make it work on splunk.&lt;BR /&gt;
I am not that much into javascript.&lt;BR /&gt;
do we need to add this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   require([    
    "splunkjs/ready!",    
    "splunkjs/mvc/simplexml/ready!"    
], function(
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Simple javascript code is like this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script&amp;gt;
 $(document).ready(function() {

    $('.faq_question').click(function() {

        if ($(this).parent().is('.open')){
            $(this).closest('.faq').find('.faq_answer_container').animate({'height':'0'},500);
            $(this).closest('.faq').removeClass('open');

            }else{
                var newHeight =$(this).closest('.faq').find('.faq_answer').height() +'px';
                $(this).closest('.faq').find('.faq_answer_container').animate({'height':newHeight},500);
                $(this).closest('.faq').addClass('open');
            }

    });

});
&amp;lt;/script&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sorry if this question sounds silly.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 10:40:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-work-with-javascript-in-splunk/m-p/155144#M9483</guid>
      <dc:creator>ektasiwani</dc:creator>
      <dc:date>2015-08-05T10:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to work with javascript in splunk</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-work-with-javascript-in-splunk/m-p/155145#M9484</link>
      <description>&lt;P&gt;You can't add javascript directly to a Simple XML Dashboard. Create a file in &lt;CODE&gt;$APP_HOME/appserver/static&lt;/CODE&gt;, let's call it "dashboard.js". Place this code into it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require( "jquery", function($) {

$(document).ready(function() {

 $('.faq_question').click(function() {

     if ($(this).parent().is('.open')){
         $(this).closest('.faq').find('.faq_answer_container').animate({'height':'0'},500);
         $(this).closest('.faq').removeClass('open');

         }else{
             var newHeight =$(this).closest('.faq').find('.faq_answer').height() +'px';
             $(this).closest('.faq').find('.faq_answer_container').animate({'height':newHeight},500);
             $(this).closest('.faq').addClass('open');
         }

 });

});

});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once you have that in place with the correct permissions, restart Splunk web. This will pull the Javascript and work accordingly. &lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 13:51:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-work-with-javascript-in-splunk/m-p/155145#M9484</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2015-08-05T13:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to work with javascript in splunk</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-work-with-javascript-in-splunk/m-p/155146#M9485</link>
      <description>&lt;P&gt;Additionally, look at &lt;A href="https://splunkbase.splunk.com/app/1603/"&gt;https://splunkbase.splunk.com/app/1603/&lt;/A&gt; for many more examples adding little snippets of JS to SimpleXML dashboards.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 15:33:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-work-with-javascript-in-splunk/m-p/155146#M9485</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-08-05T15:33:20Z</dc:date>
    </item>
  </channel>
</rss>

