Dashboards & Visualizations

Edit XML disables Javascript?

Cardonymous
Explorer

Hello,

 

I added some Javascript functionality to my multi selections (see: https://www.advisori.de/splunk-struggles-with-multiselects-and-how-to-rule-them-all-or-at-least-some...).
The script works totally fine and works for my dashboard, until I edit the XML. 

If I click edit, change some code and click either save or discard, the multi selections behave as if the script would not exist. That means the automatic option removal is not working at all anymore. 
Clearing the cache locally in my browser or using the _bump endpoint solves the problem and makes the dashboard and the script work fine again -  just until the XML is edited again.

Is there a better (permanent) solution except for clearing the cache after each edit?
Thanks in advance!

Labels (2)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@Cardonymous 

In any dashboard with Javascript Extensions, when you edit the XML it will not impact immediately after saving . You need to reload the dashboard again to get javascript executed. So when you edit the dashboard XML and save it , you need to reload dashboard. 

If you had selected the inputs values during edit OR before edit, that values might impact the behaviour of dashboard. But it is only the time of saving XML. Again after reloading the dashboard it will work as expected.

Please try it and let me know.

 

 

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Depending on what you are trying to do with the JS, you may be able to do it in SimpleXML, then you don't have to worry about JS caching. 😀

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@Cardonymous 

In any dashboard with Javascript Extensions, when you edit the XML it will not impact immediately after saving . You need to reload the dashboard again to get javascript executed. So when you edit the dashboard XML and save it , you need to reload dashboard. 

If you had selected the inputs values during edit OR before edit, that values might impact the behaviour of dashboard. But it is only the time of saving XML. Again after reloading the dashboard it will work as expected.

Please try it and let me know.

 

 

0 Karma

Cardonymous
Explorer

@kamlesh_vaghela 

Oh yes indeed, you are right. That works for me, thanks a lot!

So JavaScript will only be executed when initially loading the dashboard?

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Yes, Javascript will be load during the initialisation of supporting javascript which will happen on fresh load of dashboard.

🙂 

Cardonymous
Explorer

Thanks a lot for your explanation 😊

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 ...