Add x-target
response code modifiers
#78
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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