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
Legend

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.

 

 

View solution in original post

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
Did you miss .conf21 Virtual?

Good news! The event's keynotes and many of its breakout sessions are now available online, and still totally FREE!