htmx icon indicating copy to clipboard operation
htmx copied to clipboard

Add Hx-Swap header to the request

Open Declow opened this issue 1 year ago • 3 comments

I have a situation where I want to change the behavior of my response to the client depending on the swap attribute.

I'm trying to develop a framework that uses HTMX and the user can define everything that is available in HTMX. This means that I can only know at the time of the request if the content should be swapped completely or if its only a partial replacement of the element.

It would make my life easier if the request also had an header like Hx-Target but with the swap value like Hx-Swap.

Edit: I've changed it to be an implementation in the getHeaders function and changed it according to the feedback from @scrhartley Fork dev branch

What do you think? Do you want to support this feature?

Declow avatar Dec 19 '23 22:12 Declow

Looks like something that backends could use to tailor their responses to the use case at hand. I'd be for inclusion as a standard request header.

svenberkvens avatar Dec 20 '23 21:12 svenberkvens