imacrayon / alpine-ajax

An Alpine.js plugin for building server-powered frontends.
https://alpine-ajax.js.org
MIT License
642 stars 13 forks source link

Redirects don't work #24

Closed delaneyj closed 1 year ago

delaneyj commented 1 year ago

If a POST send a 302 it should support changing the window.location. This can happen for example with a validated form instead of returning an updated form with errors it sends the user to the newly created resource.

gabriel-aires commented 1 year ago

I second this. The existing functionality of alpine-ajax is great already. The only thing preventing me from using it instead of htmx is the handling of redirects after form submissions.

imacrayon commented 1 year ago

This makes sense. I've been leaving x-target off of forms when I want them to redirect, but now I realize doing so creates an inconsistent validation experience.

I'll play around with this and figure out what would make a good default. I think there would also need to be a x-target.follow modifier or something in cases when you might not want window.location to change.

gabriel-aires commented 1 year ago

Additionaly, I'd just like to say thank you for the amazing work on this library. The API is a breeze of fresh air compared with the alternatives.

delaneyj commented 1 year ago

:rocket: