You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An element has the attributes hx-target, hx-swap, and hx-select. When the service called from htmx responds with the correct document the behaviour is correct, htmx takes a fragment of the document based on hx-select and swaps it with the style and target we have specified. However, when the service replaces hx-target and hx-swap with their respective headers (HX-Retarget and HX-Reswap) htmx still takes into consideration the hx-select attribute we have set on the element, this can cause errors where no UI is updated, mainly because htmx looks for a fragment on our response that does not exist.
Possible solutions
HX-Reselect: I have experiment with it, but I have not been able to find a way to "reset" the behaviour, htmx always tries to find a way to select a fragment from the response. Maybe I'm wrong and there is actually a way to do so
Not using hx-select: It could be a good alternative, however I do consider there should be a way of "resetting" its behaviour
Implementation
Just like the swapStyle we could implement some sort of keyword that blocks completely the check of fragments when hx-select or HX-Reselect have been specified. maybe some sort of "none"?
The problem
An element has the attributes hx-target, hx-swap, and hx-select. When the service called from htmx responds with the correct document the behaviour is correct, htmx takes a fragment of the document based on hx-select and swaps it with the style and target we have specified. However, when the service replaces hx-target and hx-swap with their respective headers (HX-Retarget and HX-Reswap) htmx still takes into consideration the hx-select attribute we have set on the element, this can cause errors where no UI is updated, mainly because htmx looks for a fragment on our response that does not exist.
Possible solutions
Implementation
Just like the
swapStyle
we could implement some sort of keyword that blocks completely the check of fragments when hx-select or HX-Reselect have been specified. maybe some sort of "none"?sorry for the indentation
I'd be happy to open a PR with this improvement if it is accepted
The text was updated successfully, but these errors were encountered: