Support for multiple frames in data-turbo-frame

Hi,

I have often come across situations where we need to use one form to update multiple frames on a page, and althought streams is somewhat a solution around this I think the ability to specify multiple frame targets in the data-turbo-frame attribute would be pretty powerful addition to simplifying complex layout updates.

Similar to how Stimulus assigns multiple controllers, I see it being simply being able to specify multiple frame separated by a space.


<form action="/" data-turbo-frame="one two">
 <button>Submit</button>
</form>

<turbo-frame id="one">
</turbo-frame>

<turbo-frame id="two">
</turbo-frame>

I tried to look into code to do a PR, but I’m no JS guru and couldn’t get around it (

Anyone else support this idea? would happy to sponsor anyones time to make this possible as I think it would be a worthwhile feature, and would delete alot of uneeded streams code in our application :slight_smile:

4 Likes

I’m curious if this capability exists with Turbo alone or if Stimulus is also required.

Hi,

Is there a solution to this? I have two frames, an object-grid and a frame containing filters. When the filters change, I need both the grid and the filters to update.

Any ideas?

I have couple more scenarios:

  1. Updating breadcrumbs (I add “search results” item when searching in some list)
  2. Adding flash messages

I solved it with turbo-streams, but this requires to have 2 slightly different templates for regular page load and turbo-frame request, which is a bit redundant.

You can send a turbo-stream along inside a turbo frame response. It’ll get pulled out and put where its intended, even if that’s not part of the current/target frame.