Hacker News new | ask | show | jobs
by WD-42 1 day ago
Why are you expected to send down the whole thing? Maybe I’m missing something, but when you send the request from the form the response is just a partial of the results on the right hand side, using hx-target to specify some div instead of replacing the form. Form just stays there?
1 comments

To sync the form state based on the current selections in the form. This is often called facets. The form contained many options and as you filtered those options would change. So you need a way to update the form too. Hence, compute the full thing on the server (the form state, the options within the fields, and the results) then send it all back.
Can be done by updating the form fields dynamically as they are edited. Doesn’t need to be done all in one shot. Eg: on blur of each field, send an htmx request and update the other fields. On form submit with htmx, send only the results partial.