Open AdilDalli opened 7 months ago
So what? Is this a request, a question or just something to keep the electrons busy?
I don’t really get it, I’m afraid, but it looks like a job for Batman HX-Retarget and/or -Reswap.
Oh, perhaps hx-select
on the hx element is more what you need. It would cherry-pick an ID to swap. Then there’s multiselect as extension to extend hx-select's brain mass. And it’s free,99.
So what? Is this a request, a question or just something to keep the electrons busy?
It's a request for a feature that is taking shape in my mind like magic.
Oh, perhaps
hx-select
on the hx element is more what you need. It would cherry-pick an ID to swap. Then there’s multiselect as extension to extend hx-select's brain mass. And it’s free,99.
You are in the right direction. Currenly HTMX, which is in the client, needs to know which ids to swap before getting the response from the ouside (server). I want a way to tell HTMX which ids to swap based on the header (for example) of the response. We currently trigger events based in the response. but this results in a number of GETs. If we have such a feature in HTMX we would sends only one request, render the html elements in the server, and pack them to the client where HTMX will handle the swapping. prior to sending the request we might not know which elements to swap after the response.
I think that’s possible with the HX-Reswap response header then.
But I don’t know if you'd like it. The full document will be downloaded and processed. It may look smooth, but there’s still that full payload to carry and select from.
If that’s the way you want it, idiomorph (also bigskysoftware) used as extension might be the better choice.
This is not what I am aiming. The rendered html will be provided by the server and it's up to HTMX to place/swap the right element according to the configuration (in the very HMTL response).
I am digging a little bit into the swap mechanism to understand how to pass the elements ids before swapping.
Required Feature
Currently we are using events to deal with this scenario, but that results in a number of GETs that can be avoided if we use the reuturned HTMX to updated the HAS-TO-BE-UPDATED elements.
Scenario User: connect to the server to login System: returns an HTML view rendered. (see the attached file) User:enters some text on the first firstName System:Automatically updates the other fields based on the entered value.
Current Approach when the user enters some text in the firstName name text field, the element sends a post request to the server. The server then processes the request and generates the html response. in the header of the response, the event names respective to each to-be-updated element. HTMX sends GETs request based on the configuration.
.
The context
We are working on a components kit in java.