I have used htmx before and want to test Turbo now. I think my mindset is still rooted in htmx, which is way Turbo is not working for me and I need some help.
In htmx if I want to swap a page element, I respond to a frontend request with just the new element and the id of what to replace, nothing more i.e. not a full page. I’m trying to achieve the same behavior with Turbo but failing. I’ve seen people describe using Streams (e.g. Form does not update turbo-frame - #2 by remast) in the way I want.
I’m sending a POST request with a form (which is not inside a turbo frame, as per the post above):
text/vnd.turbo-stream.htmlis not in the accept headers (Turbo Handbook says it should)
- I respond with (see below) and add the MIME type from the previous point
<turbo-stream action="replace" target="uuid-form-body"> <template> <h1>UPDATED</h1> </template> </turbo-stream>
- I’m redirected to the form’s
actionurl and see a sea of nothingness instead of, at least, “UPDATED”
What am I doing wrong? Should I use a frame instead and if so do I always need to respond with the full page so that Turbo diffs it?
NOTE: I am using Clojure in my project, not Ruby.