htmx
htmx copied to clipboard
hx-swap-oob adding a new table row only adds the <td>'s and strips the wrapping <tr>
When you attempt an oob-swap on appending a <tr> to a <tbody> the <tr> is stripped and only the <th> and <td> tags are actually added. That makes the documentation example incorrect. Specifically the Updating Other Content example for Solution 2: Out of Band Responses doesn't work.
I posted this issue on Stack Overflow here. So you can see my full code and the corresponding answer there.
The solution is to put the hx-oob-swap on a <tbody> tag and wrap the <tr> tag. I was told in the discord chat that this was a bug and the example in the docs should work as is. Maybe update the docs until the bug is squashed?
I run into same issue, and to isolate issue from rest of my code, I made repository with the "update other content" example implemented (https://github.com/kimmoeklund/htmx-examples-with-zio) using zio and scala3. After completing the example, I found this solution, but I guess someone might be interested in zio + scala3 implementation of the example. Maybe I add more of the examples to the repository as my htmx learning proceeds.