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!

Celebrate CX Day with Splunk: Take our interactive quiz, join our LinkedIn Live ...

Today and every day, Splunk celebrates the importance of customer experience throughout our product, ...

How to Get Started with Splunk Data Management Pipeline Builders (Edge Processor & ...

If you want to gain full control over your growing data volumes, check out Splunk’s Data Management pipeline ...

Out of the Box to Up And Running - Streamlined Observability for Your Cloud ...

  Tech Talk Streamlined Observability for Your Cloud Environment Register    Out of the Box to Up And Running ...