Refresh a block after Submit a Form

Can I refresh a block after a Form submit with a custom code? I already use a custom code to refresh the page after Form submit but I want to refresh just one block, not the entire page.

The code I use bellow:

<script> 

window.addEventListener('submit-form-success-form1', () => { 

  setTimeout(() => { 

               window.location.reload() 

        }, 1000); 

}); 

</script>

Yes.

Which blockID do you want to refresh? and what is the block type?

1 Like

The blockID I want to refresh is: tilefona-enimerosis-ipostatikou. The block type is the new Grid Block (type Horizontal card).

I add records to the block from the Form, not the TOPBAR BUTTON, because I need to use the steps and conditions from the Conditional Form. For the Form Ending I want to enable the Submit another option which refresh the form. That’s why refresh the entire page does not work for me.

Okay and one last question: this form is inside the page where the grid block is or is it a form within a modal (lateral modal or centered modal)?

If inside the page where the grid block is, please insert the following code in the page settings (where the grid block is), custom code, header:

<script> 
window.addEventListener('submit-form-success-form1', () => { 
  setTimeout(() => { 
    window.dispatchEvent(new CustomEvent('reload-block-tilefona-enimerosis-ipostatikou'));
  }, 1000); //1500 or 2000 if 1000ms is not enough
}); 
</script>

If inside a modal, please insert the following code in the modal page settings (where the form block is), custom code, header:

<script> 
window.addEventListener('submit-form-success-form1', () => { 
  setTimeout(() => { 
    window.parent.dispatchEvent(new CustomEvent('reload-block-tilefona-enimerosis-ipostatikou'));
  }, 1000); //1500 or 2000 if 1000ms is not enough
}); 
</script>
1 Like

Thank you very much, it is working great! I would like the form to be withing modal but I have it inside the page because in the form I have logics and filters based on details page record. From what I understand if I have the form in another page to open it as a modal then I can not do that.

You can do this by creating a new page with a list-details block that uses the same data source as your original item-details block, but without a top section or any other sections—just a form below it.
To access this new page within a modal, simply add a button in your original item-details block labeled “Open Details Page,” and set it to open in a lateral modal.
In this case you would use the second script I gave you, placed in the modal page settings.

Example here:
ezgif-29a68d6f4cb11d

Note that a conditional form within a top bar button is a planned feature update.

1 Like