Is it possible to make request get as turbo_stream format?
Yes, if you use it in conjunction with a
delegate turbo-frame only works for this turbo-frame, what if I want update two differents turbo-frames with one get link?
I’m not sure I understand
when I am doing submit with post method then in
view.turbo_stream.erb I can update one or more independent turbo frames, when I am doing link_to as get method then I can update only frame where link was clicked or delegated turbo frame using
Yes, you can only update one turbo-frame at a time, but just like a post method the turbo-frame can include as many turbo-streams as you want.
<turbo-frame id="turbo_frame_message_1"> <turbo-stream action="append" target="messages"> <template> <div id="message_1"> This div will be appended to the element with the DOM ID "messages". </div> </template> </turbo-stream> <turbo-stream action="prepend" target="messages"> <template> <div id="message_2"> This div will be prepended to the element with the DOM ID "messages". </div> </template> </turbo-stream> <turbo-stream action="replace" target="left-menu"> <template> <turbo-frame id="left-menu"> This div will replace the existing element with the DOM ID "left-menu". </div> </template> </turbo-stream> </turbo-frame>
You can do it. Instead of just pass the
method: :get to the
link_to helper. it will make it to be processed as a turbo_stream request.
link_to url, method: :get
@tleish what do you think of this approach? Because it’s a RailsUJS functionality with
data-action, is it backward compatible when UJS is completely removed?
@rockwell - Yes, if using UJS, then you can use
data-action as another workaround.