-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect OOB swapping of second table in a two tables page #3203
Comments
Hey, table elements such as See the "troublesome tables" section of the docs about that. Could you try encapsulating, in your server response's HTML, your second table (the oob swapped one), in a
<template>
<tr id="message" hx-swap-oob="true"><td>Joe</td><td>Smith</td></tr>
</template> Hope this helps! |
Hi,
As a matter of fact, I did try to wrap the entire table in a template but it's not working: the table is not rendered at all. When I looked inside htmx code, the fragment processed by makeFragment function is something like this:
It starts from |
There is a critical difference, the trigger is inside the header of first table:
|
Thanks for the details. Even with the following setup, I get the same result as in my previous message: <table id="myTable">
<thead>
<tr>
<th>
<input type="text" hx-get="/test" hx-trigger="input changed delay:500ms" hx-target="#tablebody" hx-swap="outerHTML"></input>
</th>
</tr>
</thead>
<tbody id="tablebody"><tr><td>Initial</td></tr></tbody>
</table>
<table id="myOobTable">
<thead><tr><th>Test OOB</th></tr></thead>
<tbody><tr><td>Initial OOB</td></tr></tbody>
</table> Server response: same as before So there's likely something else going on. May I ask again:
Thanks |
It doesn't work for me. And yes, I'm using 2.0.4. Also I'm using Edge. Initial page sent from server: Initial page rendered in browser: Server response after first input: Html rendered after first server response: Server response after second input (fully identical with first server response): Html rendered after second server response: Also, here is a screenshot with the browser after second input: |
Thanks, this helps a lot! So, if I use your initial HTML ( However, if I wrap the oob table in a <tbody id="tablebody"><tr><td>Test</td></tr></tbody>
<template>
<table id="myOobTable" hx-swap-oob="true">
<thead><tr><th> Oob header</th></tr></thead>
<tbody><tr><td> Oob col</td></tr></tbody>
</table>
</template> Notice how I wrapped Hope this helps! |
Yes, that works, thanks. |
Yeah usually we have people swapping a table element (tr td etc.) as OOB, which then works fine wrapped in a template. If you are interested in improving the docs btw, PRs are always welcome 😄 |
I have two tables, I swap regularly the tbody of the first one and OOB swap the whole second table.
After swap the inner html of the second table (with the new content) is included in the first table and the second table is not touched. Any additional swap will add the inner html of the second table again into the first table.
OOB swapping works normal if I use something else instead of second table.
Additional info (and I think here is the problem): the trigger for swap is inside the first table, more exactly in an input field in one header. I think your function makeFragment is not working correctly in this case.
Before swap:
After first swap:
After second swap:
The text was updated successfully, but these errors were encountered: