ITADN

hx-swap strips out table row tags

#3804Openfullstackplus 创建于 2026-05-18
F
fullstackpluscommented
When appending table rows to an HTML table, `hx-swap` strips out table tags starting with `<tr>`. Non-table tags are not removed. The form: <form hx-post="/workouts/<%= @workout.id %>/sets" hx-target="#added-sets tbody" hx-swap="beforeend"> The target element: <table id="added-sets"> <thead>...<thead> <tbody>...<tbody> </table> The partial returned from `hx-post`: <tr> <td><%= set[:number] %></td> <td><%= set[:exercise_name] %></td> <td> <ul class="actions no-padding"> <li>Action one</li> | <li>Action two</li> </ul> </td> </tr> What's expected to render: <tr> <td>33</td> <td>Barbell Deadlift</td> <td> <ul class="actions no-padding"> <li>Action one</li> | <li>Action two</li> </ul> </td> </tr> What's actually being rendered: 33 Barbell Deadlift <ul class="actions no-padding"> <li>Action one</li> | <li>Action two</li> </ul> When I change `<tr>` and `<td>` tags to `<div>` and `<p>`, respectively, the markup is rendered as expected.
5 条评论