All Apps and Add-ons

customJavascript - Splunk.Module.SimpleResultsTable is null or not an object

pradeepkumarred
New Member

When I use customJavascript I get javascript error Splunk.Module.SimpleResultsTable is null or not an object

View



myApp/app_testing.js

javascript


if (Splunk.util.getCurrentView().indexOf("my_view") == 0 && Splunk.Module.SimpleResultsTable) {
Splunk.Module.SimpleResultsTable = $.klass(Splunk.Module.SimpleResultsTable, {
onResultsRendered: function($super) {
var retVal = $super();
this.myCustomHeatMapDecorator();
return retVal;
},
myCustomHeatMapDecorator: function() {

0 Karma

sideview
SplunkTrust
SplunkTrust

Well, it sounds like the "my_view" view does not actually contain a SimpleResultsTable module?

Have you already switched from using SimpleResultsTable to using the Sideview Table module perhaps?

UPDATE: My apologies! We discovered following up about this that the SideviewUtils module's customJavascript, unlike application.js, gets put into the page at a point before the module classes have been loaded. This means that while this customJavascript param is still very useful for defining CustomBehavior code, and for writing JS code that doesn't need to patch the core Splunk module code, you can't use it to patch modules like this.

I will think about either changing the customJavascript param's behavior to load the code after the modules have loaded, or possibly having an optional param whereby the app-developer can specify to some degree when it should be stitched into the page.

In the meantime you'll have to keep applying your module patches from application.js.

0 Karma

sideview
SplunkTrust
SplunkTrust

I'm afraid it's complex and it depends on what exactly you're patching. Your patch might come in and modify a class after all the instances are already made, or the opposite, or in the middle you might patch for instance the Context class, such that some of the instances as the page was loading will be unpatched, and the instances created afterwards are the patched ones. "Patching", while simple sometimes, is not in general for the faint of heart and for this reason it's better to use a Sideview customBehavior where you hit one of these complex requirements.

0 Karma

justgrumpy
Path Finder

I am doing something very similar in my customJavascript. I put the "patch" inside of $(document).ready() and am having no issues with it. Is there a problem with my approach? Should I move the "patch" to application.js?

The new Table module has a customBehavior parameter. Should it let you capture the onResultsReady event? I couldn't seem to get it to with Sideview Utils 2.2.8.

0 Karma
Get Updates on the Splunk Community!

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...