How to run custom JavaScript when app is ready?
How to run custom JavaScript when the website is ready?
Sometimes you need to run some JavaScript code after the website is fully rendered and all elements are ready for interaction.
If you run the code too early (before the web app is fetched all the data and complete rendering) most likely some elements will be missing or lack data.
That's why there is a special event ssViewerRendered
A working example that opens the details page by clicking on the image:
This code should be added in Settings tab.
Sometimes you need to run some JavaScript code after the website is fully rendered and all elements are ready for interaction.
If you run the code too early (before the web app is fetched all the data and complete rendering) most likely some elements will be missing or lack data.
That's why there is a special event ssViewerRendered
<script>
document.addEventListener('ssViewerRendered', () => {
// put your code here
})
</script>
A working example that opens the details page by clicking on the image:
<script>
document.addEventListener('ssViewerRendered', () => {
document.querySelectorAll('.sv-tile').forEach(tile => {
tile.querySelector('.sv-tile__image').onclick = () => tile.querySelector('.sv-tile__btn').click()
})
})
</script>
This code should be added in Settings tab.
Updated on: 28/11/2024
Thank you!