Refresh dynamic block after Call API action

<script>
window.addEventListener('block-loaded-blockid', () => {
	window.addEventListener('call-api-success-blockid', (e) => {
	setTimeout(() => {
window.dispatchEvent(new CustomEvent('reload-block-blockid'));
}, 5000);
});
});
</script>

Replace blockid with your own block name/id, adjust the timout period If needed and add the code to Page Settings>Custom Code>Header section and publish the updates afterwards

3 Likes

Hi Maria,

This doesn’t work for me on a grid view with a call API item button, any suggestions ?

Hi,

Careful, for the new blocks (labeled as beta for now) it is not window.dispatchEvent(new CustomEvent('reload-block-blockid')); but window.dispatchEvent(new CustomEvent('reload-blockid'));

1 Like

Hi, this doesn’t appear to be working for me either. Any suggestions?

Thanks!