Comments (6)
Thanks for the explanation @sstephenson. I’m probably misunderstanding something, but can’t quite see why swapping in HTML returned by the form submission (or even simulating a full page visit using the HTML response) would mess with the browser history... If the form submission is an ajax request, does the browser put the POST or PUT request in its history? If not, why would it be a problem to render HTML returned with a 200 response, in the same way 400-500 responses can now be rendered? 🙇♂️
from turbo.
Browsers record form submissions in history along with the verb. In a standard "postback" scenario, if you reload the page after submission, or navigate away and then back, you'll see a dialog box like this:
The forms-must-redirect constraint is what allows us to keep the browser's back, forward, and reload buttons working after any form submission, and without showing a dialog box, since all form submissions result in a visit and all visits are idempotent GET requests.
from turbo.
I'm running into this issue as well with simple form submissions that re-render the form (i.e. the HTML page) with errors when server validation fails. Is there a reason for this behavior? Is it documented?
from turbo.
ah so the Turbo.visit
is not a bug, it was because I had render plain https://github.com/cj/app-template/blob/main/app/controllers/test_controller.rb#L11!
from turbo.
So I ended up creating a patch for now to get it working on my end https://github.com/cj/app-template/blob/main/patches/%40hotwired%2Bturbo%2B7.0.0-beta.1.patch, but it led to what might be a bug with Turbo.visit
:
This is where I am calling Turbo.visit
https://github.com/cj/app-template/blob/main/app/components/form_component/base.js#L122
from turbo.
We intend to allow HTTP 422 responses for form submissions inside frames, but it didn’t make the cut for the initial beta release.
For now, you can try sending a Turbo Streams response that re-renders your form with errors.
from turbo.
Related Issues (20)
- Adding data-turbo-action="advance" on top of a data-turbo-frame="target" causes a full page refresh HOT 10
- Unexpected behavior when morphing a turbo frame src HOT 6
- Frame navigation broken when Turbo is used without framework integration HOT 2
- refresh="morph" in a turbo-frame morphs on a full Page Reload but fails to morph with frame.reload() HOT 1
- Add `morph` Turbo Stream Action HOT 14
- Unexpected scroll position after Turbo drive visit
- Script doesn't initialized again using form of SendPulse HOT 2
- Links with UJS like behavior are prefetched for InstantClick
- Turbo should not handle forms that target="_blank"
- Turbo 8 cannot be loaded from skypack.dev HOT 2
- Turbo Stream refresh does not work when responding to a form submission HOT 1
- InstantClick is incompatible with `data-turbo-stream` and `data-turbo-confirm` HOT 1
- InstantClick always fetches page when hovering same link within the turbo-prefetch-cache-time window. HOT 5
- Morphing between different URLs HOT 1
- Morphed Turbo frame keeps loading the same content when `turbo_frame: :_top` is used to exit it HOT 2
- Event turbo:before-render is fired twice, unless caching is disabled. HOT 7
- Support `data-turbo-frame="_parent"` in nested frames
- Morphing is updates an `a` tag, but not it's content, but only on the client who initiated the action HOT 10
- Navigating to page with non-successful response seems to reload javascript HOT 9
- Turbo doesn't send Turbo-Frame header when frame's src is updated HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from turbo.