htmx icon indicating copy to clipboard operation
htmx copied to clipboard

Out of bounds (oob) - does not replace the original element

Open helixaros opened this issue 1 year ago • 5 comments

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: Screenshot 2023-04-22 at 10 33 36 PM

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>

helixaros avatar Apr 22 '23 19:04 helixaros

anyone with similar issue?

helixaros avatar May 01 '23 12:05 helixaros

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

halitcelik avatar May 08 '23 14:05 halitcelik

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

@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

helixaros avatar May 12 '23 12:05 helixaros

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

@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?

halitcelik avatar May 12 '23 13:05 halitcelik

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

@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’

helixaros avatar May 12 '23 15:05 helixaros