This form will only update itself when submitted, with two exceptions:
If the server responds with a 302 status, the browser will perform a full page navigation to the new content
If the server responds with a 500 status, Alpine AJAX will target an element with ID critical_error instead of my_form
You can match a whole class of status codes using the wildcard syntax: x-target.4xx will match any 400 class status.
You can also match both 400 and 500 class status codes using the special error modifier: x-target.error.
This PR also adds two new events for handling responses and requests: ajax:send and ajax:sent.
ajax:send fires just before a fetch call is made, $event.detail contains all of the options that will be passed to fetch so that you can override anything.
ajax:sent fires after a fetch call is made to complement the send event. $event.detail contains the response data from the request.
This PR adds
x-target
modifiers you can use to change targets based on the response code returned from the server:This form will only update itself when submitted, with two exceptions:
critical_error
instead ofmy_form
You can match a whole class of status codes using the wildcard syntax:
x-target.4xx
will match any 400 class status.You can also match both 400 and 500 class status codes using the special
error
modifier:x-target.error
.This PR also adds two new events for handling responses and requests:
ajax:send
andajax:sent
.ajax:send
fires just before afetch
call is made,$event.detail
contains all of the options that will be passed to fetch so that you can override anything.ajax:sent
fires after afetch
call is made to complement thesend
event.$event.detail
contains the response data from the request.Resolves #73, #76