Skip to content

event.detail.successful always true with hx-on:after-request when allowing all responses status to swap #3440

@Kabzns

Description

@Kabzns

The Problem:

allowing all responses status to swap:
<meta name="htmx-config" content='{"responseHandling": [{"code":"...", "swap": true}]}'>
Listen to hx-on:after-request on an element:
<form hx-on::after-request='if(event.detail.successful) { doSome() }>
event.detail.successful is always true, even for error (not 2xx status) responses

From the ::afterRequest Doc:

detail.successful - true if the response has a 20x status code or is marked detail.isError = false in the htmx:beforeSwap event, else false

Doesn't mention that allowing all responses status to swap will also mark the response as successful?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions