Turbo Streams without Channels? #72
Replies: 1 comment
-
1You can append a rendered comment on the submitted page without Turbo Streams, however, if you want the rendered comment to be sent to all users with that page open, you must use Turbo Streams. To have the rendered comment update without a page refresh, you must place the form inside a turbo-frame (so the form submit doesn't leave the page). The view that processes the form can then send a rendered turbo frame back to the page that submits the form using something like: form = CommentForm(request.POST)
if form.is_valid():
comment = form.save()
frame = render_frame(request, "comment_item.html", {'comment': comment}).append(id='comments_list')
return frame.response ( Please let me know if I can clarify any of this. 2Currently the only way to use turbo streams is with channels and redis. |
Beta Was this translation helpful? Give feedback.
-
Hey all,
I'm trying to integrate Hotwire techniques in my app and have run into a couple of questions, I was hoping someone could help me with.
I have 2 models (Project and Comment) where Project can have many comments. I have added a CommentCreateView on my ProjectDetailView via turbo-frame and now there is no page reload after comment is submitted. I also added ListView to my DetailView, so that I can see all the comments about the Project. After comments is submitted, new comment doesn't render out unless I reload the page, even though I have it under turbo-frame as well. Do I understand correctly that for the list of comments to get updated, I must use Turbo Streams?
Is there a way to use Turbo Streams without channels (and redis)? Or is this the only way?
Thanks a ton in advance.
Beta Was this translation helpful? Give feedback.
All reactions