bigskysoftware / bigskysoftware/htmx-extensions

response-targets: add support for hx-swap-... overrides

Open
#87 4 comments 4 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
284
Forks
88
PR merge metrics
No merged PRs in 30d

Description

Hi guys,

First of all, thanks for the great work on HTMX and its extensions. I just started a new project with it, and I must say I'm surprised how convenient it is to work with.

I ran into one issue though with the `response-targets` extension: it would be really handy if it was possible to override the `hx-swap` attribute similarly to `hx-target`, because the two are tightly related.

In my specific case, I'd need to replace a `delete` swap rule with `innerHTML`. I know I could tweak my components and API to be able to use the same swap rule, but that would really degrade the code (especially the API). My current workaround is to include a custom header in the HX request that triggers a custom "reswap" logic (`HX-Reswap` response header) on the backend, effectively implementing `hx-swap-` manually on the backend, but solving this problem with an `hx-swap-` attribute in the HTML would be way cleaner and more elegant in my opinion.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.