Can someone assist with a bit of custom code for reloading a page after a button press in a list block (table format)? The use case is when a a record is deleted from the table, the page should be reloaded to recalculate related data on the page. Seems to not be difficult but I’ve tried several from here and chatgpt but no luck. A million thanks
Hi Daisy:
This is the script to be added in the custom code header, in the page settings:
<script>
window.addEventListener('block-loaded-table1', () => {
window.addEventListener('delete-record-success-table1', () => {
setTimeout(() => {
window.location.reload();
}, 1000);
});
});
</script>
Just replace table1, line 2 and line 3, by your block ID.
The page reload will occur after 1 second (1000 ms). You can adjust it yourself (line 6)
1 Like
Yes! It worked! Thanks Matthieu! What would be the script for Edit Qty scenario? This is an edit action modal scenario (see below)
This would be:
<script>
window.addEventListener('block-loaded-table1', () => {
window.addEventListener('update-record-success-table1', () => {
setTimeout(() => {
window.location.reload();
}, 1000);
});
});
</script>
1 Like
Worked perfectly! Thanks so much Matthieu!
1 Like