Skip to content
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

hx-target-2* ignores hx-swap #93

Open
gogognome opened this issue Sep 25, 2024 · 1 comment
Open

hx-target-2* ignores hx-swap #93

gogognome opened this issue Sep 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@gogognome
Copy link

In a Django project I have this fragment of HTML:

                <tr id="new-item-name-row">
                    <th class="row-header">
                        <form
                                id="new-name-form"
                                hx-ext="sl-button"
                                autocomplete="off"
                                hx-post="{{ new_item_url }}"
                                hx-target="#new-item-name-row"
                                hx-target-4*="#new-item-name-row"
                                hx-target-5*="html"
                                hx-swap="outerHTML"
                                hx-indicator="#spinner-new-name">

When the form is submitted, and a 200 response is returned, then the response contains two tr elements: one that replaces the row with id new-item-name-row and a second row with the new item.

This works fine. But when I replace hx-target by hx-target-2*, then the form element gets replaced by the two rows, which completely screws up the table.

If I change the view code to return a 409 status instead of status 200, then it works perfectly.

Is this a bug in the extension?

@Telroshan
Copy link
Collaborator

Definitely sounds like a bug indeed. could it be that response-targets doesn't get processed and htmx uses its default hx-target value (i.e. this) which could explain what your form itself gets replaced?
If you'd like to investigate, please feel free to do so! bugfix PRs are much welcome

@Telroshan Telroshan added the bug Something isn't working label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants