The link I provided is an example of using superClass = Splunk.Module.DispatchingModule
http://dev.splunk.com/view/SP-CAAADXX#Todefineyourcustommodule
that basically displays data after job done, see you have some backend job that gets data to display.
Let me use your example to bind an event, for example:
a. I create a button in the file CustomModule.html as a single line content:
Click Me!
b. I create another file CustomData.html to display data as below:
% if ( mydata 😞
Data passed into mako
${mydata}
% else:
Nothing
% endif
c. In CustomModule.py, I made the changes to render CustomData.html instead:
def generateResults(self, host_app, client_app, savedSearchName=None):
mylist = ['A','B','C','D','E']
mydict = {'mylist':mylist}
return self.controller.render_template('CustomModule/CustomData.html', dict(mydata=mylist))
d. Now, in CustomModule.js, I bind the click event of mybutton, call getResults() while clicking:
Splunk.Module.CustomModule= $.klass(Splunk.Module, {
initialize: function($super, container) {
$super(container);
$(document).find('.mybutton').click(this.onMyButtonClick.bind(this));
},
onMyButtonClick:function() {
this.getResults();
}
})
So the outcome is:
a. first, it shows up the button only.
b. when you click on button, you get data displayed underneath.
This gives you an example to bind an event for getting data.
... View more