0

I'm creating a table and I want to render a turbo-frame tag around each row.

Here's the code in an html.erb file (see line 7).

 1. <table class="min-w-full divide-y divide-gray-300">
 2.   <thead>
 3.     ...
 4.   </thead>
 5.   <tbody>
 6.     <% current_organization.users.each do |user| %>
 7.       <%= turbo_frame_tag member do %>
 8.         <%= render partial: "user/row", locals: {user: user} %>
 9.       <% end %>
10.    <% end %>
18.   </tbody>
19. </table>

Inspecting the generated HTML, the turbo-frame tags are rendered outside of the table and have no content in them (see lines 1 and 2).

1. <turbo-frame id="user_2"></turbo-frame>
2. <turbo-frame id="user_3"></turbo-frame>
3. <table>
4.   ...
5. </table>

Any idea why this is happening?

John
  • 9,254
  • 12
  • 54
  • 75
  • only a few tags are allowed inside a table: thead, tbody, tr ... https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table. why do you need all these turbo frames? – Alex Nov 27 '22 at 12:07
  • Thanks, @Alex. I thought that might be the case, but I didn't expect that to be enforced by Rails or TurboFrames. Is it the browser doing it? I need those TurboFrames around each row so they can be dynamically updated via TURBO_STREAM responses. – John Nov 27 '22 at 15:24
  • enforced by the browser. you don't need turbo frame for that, just add unique `id` on `tr` tags. – Alex Nov 27 '22 at 16:59

0 Answers0