Dashboards & Visualizations

What Javascript framework is this line?

josefa123
Explorer
mvc.Components.get('highlight').getVisualization(function(tableView)

I've been searching a lot on where do I find this line of code on many frameworks but unfortunately I can't find any. Can you point me to the right direction? Because I really want to know what the code really does and I want to utilize it to what I want to do. Thank you so much. Any help would be appreciated.

0 Karma
1 Solution

jeffland
SplunkTrust
SplunkTrust

Unfortunately, I can't point you to some hard evidence in the form of comprehensive documentation. From experience however I can tell you what this is used for: when you create components in Simple XML on a dashboard and you want to do something with it in javascript (e.g. add a custom table cell renderer to a table, change the options of a multiselect, listen to changes on inputs and much more). See here for a simple example, here for a more comprehensive one, and here for the (mostly) complete reference of this web framework.
There are two such methods: mvc.Components.get(), which will only work when the object is already there and throw an error if it isn't, and mvc.Components.getInstance() will create the object if it doesn't already exist - see this question here.

Generally, the frameworks used are listed here, so you will have to find most of the methods described within those (most importantly to you as a developer, backbone.js and jquery.js). However I have to admit that it can be frustrating sometimes, because for instance both backbone.js and jquery.js provide a method to listen to events with .on("change", someHandler), but their functions use slightly different syntax and you're left to figure out which one to use.

In the case of the get() you mentioned, I'd say it comes from backbone.js because it is in the class mvc which is also from backbone.

View solution in original post

0 Karma

jeffland
SplunkTrust
SplunkTrust

Unfortunately, I can't point you to some hard evidence in the form of comprehensive documentation. From experience however I can tell you what this is used for: when you create components in Simple XML on a dashboard and you want to do something with it in javascript (e.g. add a custom table cell renderer to a table, change the options of a multiselect, listen to changes on inputs and much more). See here for a simple example, here for a more comprehensive one, and here for the (mostly) complete reference of this web framework.
There are two such methods: mvc.Components.get(), which will only work when the object is already there and throw an error if it isn't, and mvc.Components.getInstance() will create the object if it doesn't already exist - see this question here.

Generally, the frameworks used are listed here, so you will have to find most of the methods described within those (most importantly to you as a developer, backbone.js and jquery.js). However I have to admit that it can be frustrating sometimes, because for instance both backbone.js and jquery.js provide a method to listen to events with .on("change", someHandler), but their functions use slightly different syntax and you're left to figure out which one to use.

In the case of the get() you mentioned, I'd say it comes from backbone.js because it is in the class mvc which is also from backbone.

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...