Replies: 2 comments 1 reply
-
|
You may want to have a look at https://htmx.org/extensions/idiomorph/ |
Beta Was this translation helpful? Give feedback.
-
|
Yes this is a known issue in idiomorph as it will overwrite input values every time and ignore user input changes. Great for resetting forms but not ideal most of the time. Someone a while ago proposed retaining user input on morph but this would be kind of a breaking change in behavour. I have a PR up bigskysoftware/idiomorph#146 that resolves this by adding a new idiomorph option to keep the inputs preserved and has a good performance optimization around this as well. Would be good to test this PR version with your situation if possible. Also htmx4 which is under active development right now has built in morph right now in the current Alpha that should always preserve input values as well you could test out. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've built site with many dynamic forms. I've been using a pattern like this:
and then my submit button is something like:
the requests with
is_checkperform validation and dynamic form updating (e.g. if the contents of a field change depending on the value of a different field), andis_check: falseperform submission.the fact that my form is re-rendered whenever the contents change causes several problems. this is especially apparent with
<input type="text"elements. with a flow like:<selectelementstep 2 is a little odd. the
blurevent of the text field causes thechangeevent of the form to trigger, which submits the form data and re-renders the form. this means that if at step (2), i click on a select, the select will flash open, then close as it's re-rendered by the browser. likewise, if at step (2) i click on thesubmitbutton, nothing happens. this is i think because the element is currently being re-rendered -- maybe there's no button even there to click on for a moment?i've tried to solve this problem in several ways.
selectdropdowns that are not dynamic, i've been addinghx-preserve. but if the contents of the select do change based on the input, i obviously can't do that.submitbuttons, this is a more annoying problem, since it just kind of feels like the button doesn't work and you get no feedback. i tried addinghx-sync="closest form:replace"to thesubmits, but this on it's own is not enough. the blur event seems to have already been dispatched, and it's too late to replace theis_checksubmit. it seems to work when i combine the parent form'schangewithhx-trigger="change delay:100ms", with the100mssomewhat experimentally derived.50msseems too slow. but this pattern seems kind of ... hacky?curious if i'm missing something obvious. am i just doing it wrong, or is there a solution for this, idk what to call it, "flash of noninteractivity" (kind of like the old-school flash of unstyled content).
Beta Was this translation helpful? Give feedback.
All reactions