htmx
htmx copied to clipboard
Out of bounds (oob) - does not replace the original element
I have the case below where my original.html contains the button that will be replaced when clicked, with a new button coming from the file to_replace.html
However in my case both buttons remain on the screen:
original.html
<tbody>
<tr id="addItemButtonRowId">
<td class="small fw-bold" colspan="5">
<button
id="addItemBtnId"
hx-get="{% url ' %}"
hx-target="#addItemButtonRowId"
hx-swap="beforebegin"
class="btn btn-outline-primary" type="button"
> + Add an item</button>
</td>
</tr>
</tbody>
to_replace.html
<button
id="addItemBtnId"
hx-get="{% url '' %}"
hx-target="#addItemButtonRowId"
hx-swap="beforebegin"
hx-swap-oob="true"
class="btn btn-outline-primary" type="button"
> +
Add an item
</button>
anyone with similar issue?
Your html has hx-swap="beforebegin"
and the documentation says
beforebegin | prepends the content before the target in the targets parent element |
---|
I think it should be outerHTML
Your html has
hx-swap="beforebegin"
and the documentation saysbeforebegin prepends the content before the target in the targets parent element I think it should be
outerHTML
@halitcelik unfortunately the suggestion you have provided doesn't work. from my understanding the "beforebegin" is only used to place the element on at the beginning of the hx-target which is before the
Your html has
hx-swap="beforebegin"
and the documentation says beforebegin prepends the content before the target in the targets parent element I think it should beouterHTML
@halitcelik unfortunately the suggestion you have provided doesn't work. from my understanding the "beforebegin" is only used to place the element on at the beginning of the hx-target which is before the with id #addItemButtonRowId
Well, you seem to be replacing a tr
with a button. Might that be the problem?
Your html has
hx-swap="beforebegin"
and the documentation says beforebegin prepends the content before the target in the targets parent element I think it should beouterHTML
@halitcelik unfortunately the suggestion you have provided doesn't work. from my understanding the "beforebegin" is only used to place the element on at the beginning of the hx-target which is before the with id #addItemButtonRowId
Well, you seem to be replacing a
tr
with a button. Might that be the problem?
That is very possible, but my button that contains all the hx attributes is inside the
How can i rewrite it in such a way that the hx-oob is set on the ‘tr’