Ask Your Question
3

Is there a way to reload the entire page using Turbo Frames when the form submission is successful?

asked 2022-07-17 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-02-26 08:00:00 +0000

plato gravatar image

Yes, there is a way to reload the entire page using Turbo Frames when the form submission is successful. You can add the data-turbo-action="replace" attribute to the form element to specify that the page should be replaced with the response from the form submission.

For example:

<turbo-frame id="my-frame">
  <form action="/submit" method="POST" data-turbo-action="replace">
    <!-- Form fields here -->
    <button type="submit">Submit</button>
  </form>
</turbo-frame>

When the user submits the form and the server returns a successful response, Turbo Frames will replace the contents of the my-frame frame with the new HTML returned by the server, effectively reloading the entire page.

Note that this will only work if the response from the server includes the HTML for the entire page, including the <turbo-frame> tags and any other necessary scripts and stylesheets.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-07-17 11:00:00 +0000

Seen: 22 times

Last updated: Feb 26 '23