Replies: 1 comment
-
I tried to add a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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'm having trouble with Alpine forms that submit to a form-processing page.
If you hit "back" after submitting, then when you return to the form, the form elements and the underlying x-model data are out of sync. (It seems like only "text" inputs are properly updated)
Likewise if you use a
<input type="reset"/>
then when it's clicked the form elements reset, but the x-model is not updated.It seems like the browswer (Chrome 93.0.4577.82) does not consider "reset" or "going back to the form" as something that fires
x-on:change
or otherwise update the x-model.See https://codepen.io/tmalaher/details/bGRmGPQ
Try this:
Also problematic: I can't figure out what value is going to get submitted for a checkbox. the "value" attribute or "true".
[Background:
I was converting an old crufty jQuery form to alpine. Everything is much simpler.
However the old form, since it was using
$('#field').val()
and the like as it's "data model", it had no difficulty dealing with the browser back button and form reset behavior. Whatever was in the form was the value. Period.]
Beta Was this translation helpful? Give feedback.
All reactions