Async form submission #2744
acalvino4
started this conversation in
3. Feature Ideas
Replies: 1 comment
-
You can define custom directives in alpine v3 so you could potentially write something already. That blog article looks a bit old, modern browsers support fetch. About the syntax, yoy could have something like that <form x-async="promise => promise.then(response => {doSomething})"> |
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
-
Problem
Converting a form to be submitted asynchronously is more of a chore than it seems it should be.
The basic idea here is to reduce boilerplate and make asynchronous forms declarative.
Don't get me wrong, it's very doable, and there are many blogs, such as this which outline the steps. There are a couple reasons I don't like this approach:
On the other hand, it would be awesome and ideal to bake this into alpine bc:
Proposal
<form x-async method=...
x-success
andx-failure
which case take functions. The above functionasyncSubmit
would then be extended to retrieve the response promise fromxhr
and execute the appropriate functions onreject
andresolve
Alternatively, just a single
x-form
attribute thatreject
andresolve
The more I think about this, the more it seems this would probably fit better in a plugin than core.
Beta Was this translation helpful? Give feedback.
All reactions