<?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: Using javascript (Modal) for pop-up in dashboard in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-javascript-Modal-for-pop-up-in-dashboard/m-p/459095#M45461</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;a little mistake on line 14 in app.js : &lt;BR /&gt;
Replace&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ], function(_, Backbone, mvc, ModalView) {
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;by &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ], function(_, Backbone, mvc, tableview, ModalView) {
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;after this correction, don't forget to use the _bump to reload changes from static files : http://$SPLUNK_URI$/en-US/_bump &lt;/P&gt;

&lt;P&gt;You will be able to view some change on click, but you will have to continue to adapt the script and css to obtain a better result.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 01:51:43 GMT</pubDate>
    <dc:creator>thomasroulet</dc:creator>
    <dc:date>2020-09-30T01:51:43Z</dc:date>
    <item>
      <title>Using javascript (Modal) for pop-up in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-javascript-Modal-for-pop-up-in-dashboard/m-p/459094#M45460</link>
      <description>&lt;P&gt;I am trying to use the idea in the below link to make a pop-up window in my dashboard.&lt;/P&gt;

&lt;P&gt;reference link : &lt;A href="https://www.hurricanelabs.com/splunk-tutorials/splunk-custom-modal-view-creation-part-1-revealing-a-path-toward-enhanced-visibility-and-functionality"&gt;https://www.hurricanelabs.com/splunk-tutorials/splunk-custom-modal-view-creation-part-1-revealing-a-path-toward-enhanced-visibility-and-functionality&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;But unfortunately, for even a simple xml dashboard, I am not able to get the pop-up at all (I am not even sure if the javascript is loading)&lt;/P&gt;

&lt;P&gt;Below are the codes...&lt;/P&gt;

&lt;P&gt;Simple xml dashboard :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="app.js"&amp;gt;
&amp;lt;label&amp;gt;Modal Demo&amp;lt;/label&amp;gt;
&amp;lt;row&amp;gt;
&amp;lt;panel&amp;gt;
  &amp;lt;table id="master"&amp;gt;
    &amp;lt;title&amp;gt;Master&amp;lt;/title&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;index=_internal | stats count by sourcetype&amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;-60m@m&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
    &amp;lt;/search&amp;gt;
    &amp;lt;option name="drilldown"&amp;gt;row&amp;lt;/option&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;app.js : (placed inside $SPLUNK_HOME$/apps/retail/appserver/static)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require.config({
paths: {
ModalView: '../app/retail/ModalView'
}
});

require([
'underscore',
'backbone',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'ModalView',
'splunkjs/mvc/simplexml/ready!'
], function(_, Backbone, mvc, ModalView) {

//get an instance of the master table
var master = mvc.Components.get('master');

master.on("click", function(e) {
     e.preventDefault();
    if (e.field === "sourcetype") {
        e.preventDefault();
        //pass the value of the item we clicked on to the title variable
        var _title = e.data['click.value'];
        var modal = new ModalView({ title : _title });
        modal.show();
    }
 });

});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;ModalView.js (placed inside $SPLUNK_HOME$/apps/retail/appserver/static/components )&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;define([
'underscore',
'backbone',
'jquery',
'splunkjs/mvc/searchmanager'
], function(_, Backbone, $, SearchManager) {

var modalTemplate = "" +
            "&amp;lt;div class=\"modal-header\"&amp;gt;&amp;lt;h3&amp;gt;&amp;lt;%- title %&amp;gt;&amp;lt;/h3&amp;gt;&amp;lt;button class=\"close\"&amp;gt;Close&amp;lt;/button&amp;gt;&amp;lt;/div&amp;gt;" +
            "&amp;lt;div class=\"modal-body\"&amp;gt;&amp;lt;/div&amp;gt;" +
            "&amp;lt;div class=\"modal-footer\"&amp;gt;&amp;lt;/div&amp;gt;" +
            "&amp;lt;/div&amp;gt;" +
            "&amp;lt;div class=\"modal-backdrop\"&amp;gt;&amp;lt;/div&amp;gt;";

var ModalView = Backbone.View.extend({

    defaults: {
        /*default values if none are given i.e the modal’s title*/
        title: 'Not Set'
    },
    initialize: function(options) {
        /* Where initial values passed in to an instance
           of this view will be handled */
           //the options parameter allows us to pass values to our view
        this.options = options;
        //this checks for values in the default object or if a title was
        //actually passed through the options parameter
        this.options = _.extend({}, this.defaults, this.options);
        this.template = _.template(modalTemplate);
        //for testing purposes we will log out the title
        console.log('Hello from Modal View: ' + this.options.title);
    },

    events: {
        /* events such as the click of a button */
    },

    render: function() {
        /* renders the view */
        /* Define the data object where we specifically set 
 the title value here it is what we pass into the new instance of 
 the this view in app.js
 */
 var data = { title : this.options.title }
 //take our data object and pass it to our template
 this.$el.html(this.template(data));
 return this;
    },

    show: function() {
        /* actually shows the modal window*/
         //append the modal to the document.body and call this view’s
        //render function
        $(document.body).append(this.render().el);
    },

   close: function() {
        /* handles the closing of the modal window */
          this.unbind();
          this.remove();
    }
});

//return the modal in order to access it
return ModalView;
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can somebody please help me in this regard..??&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 09:37:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-javascript-Modal-for-pop-up-in-dashboard/m-p/459094#M45460</guid>
      <dc:creator>soumdey0192</dc:creator>
      <dc:date>2019-08-22T09:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using javascript (Modal) for pop-up in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-javascript-Modal-for-pop-up-in-dashboard/m-p/459095#M45461</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;a little mistake on line 14 in app.js : &lt;BR /&gt;
Replace&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ], function(_, Backbone, mvc, ModalView) {
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;by &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ], function(_, Backbone, mvc, tableview, ModalView) {
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;after this correction, don't forget to use the _bump to reload changes from static files : http://$SPLUNK_URI$/en-US/_bump &lt;/P&gt;

&lt;P&gt;You will be able to view some change on click, but you will have to continue to adapt the script and css to obtain a better result.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:51:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-javascript-Modal-for-pop-up-in-dashboard/m-p/459095#M45461</guid>
      <dc:creator>thomasroulet</dc:creator>
      <dc:date>2020-09-30T01:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using javascript (Modal) for pop-up in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-javascript-Modal-for-pop-up-in-dashboard/m-p/459096#M45462</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;After some R&amp;amp;D I found out what was causing the issue and to my surprise it was such a simple one that I sat down with hands on my head for few minutes... &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;So for the folks, following the question, here is the simplest of solution ever can be...&lt;/P&gt;

&lt;P&gt;Solution : "Clear your browser cache every time you make changes to the JS file" &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;The answers to the below post, set me in the right direction (Not taking any credits for the solution)&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/504283/why-is-my-javascript-code-not-working-in-my-dashbo.html"&gt;https://answers.splunk.com/answers/504283/why-is-my-javascript-code-not-working-in-my-dashbo.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 11:49:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-javascript-Modal-for-pop-up-in-dashboard/m-p/459096#M45462</guid>
      <dc:creator>soumdey0192</dc:creator>
      <dc:date>2019-08-22T11:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using javascript (Modal) for pop-up in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-javascript-Modal-for-pop-up-in-dashboard/m-p/459097#M45463</link>
      <description>&lt;P&gt;Thanks @thomasroulet for you inputs... I just found out the solution after some R&amp;amp;D and yes it is the exact same thing that you posted in your answer.&lt;/P&gt;

&lt;P&gt;I also have posted my own answer..&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 11:51:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-javascript-Modal-for-pop-up-in-dashboard/m-p/459097#M45463</guid>
      <dc:creator>soumdey0192</dc:creator>
      <dc:date>2019-08-22T11:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using javascript (Modal) for pop-up in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-javascript-Modal-for-pop-up-in-dashboard/m-p/577419#M47324</link>
      <description>&lt;P&gt;What if the context in modal pop-up is not table, wat function shall i be using for a html form?&lt;/P&gt;&lt;P&gt;On button click i want to pop-up a html form.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 08:40:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-javascript-Modal-for-pop-up-in-dashboard/m-p/577419#M47324</guid>
      <dc:creator>sarvesh_11</dc:creator>
      <dc:date>2021-12-06T08:40:26Z</dc:date>
    </item>
  </channel>
</rss>

