bigskysoftware / bigskysoftware/htmx-extensions

hx-target-2* ignores hx-swap

Open
#93 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
284
Forks
88
PR merge metrics
No merged PRs in 30d

Description

In a Django project I have this fragment of HTML:



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?

Contributor guide

Open the contributing guide

Research direction

Start by locating the extension code that handles hx-target-2* and compare its 200-response path with the 409-response path. Reproduce the supplied table and form markup, including hx-swap="outerHTML" and the two returned tr elements. Done means the 200 response applies the outerHTML swap to the intended row without replacing the form with invalid table content.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.