htmx
htmx copied to clipboard
path-deps sends requests even when mutating request fails
Is it intended or is it a bug? If intended, is there a way I can turn it off?
I don't think code snippet be much help but here it is:
<div id="np-tag-list" class="d-flex flex-wrap gap-3 py-3 px-1" hx-get="/tags/" hx-ext="path-deps" hx-trigger="path-deps" hx-swap="outerHTML" path-deps="/tags/*">
<div class="btn-group">
<button type="button" class="btn btn-secondary pe-none">
Biology
</button>
<button type="button" class="btn btn-secondary" hx-delete="/tags/4/followership/">
×
</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-secondary pe-none">
Needs Review
</button>
<button type="button" class="btn btn-secondary" hx-post="/tags/6/followership/">
+
</button>
</div>
</div>
buttons with + or x text send failing post/delete requests but path-deps reloads the outer div nonetheless.
what does fail
mean in this context?
Http status code in range of [400, 599]
Two approaches come to mind:
- Leverage status codes per @Alireza-Farahani , though perhaps allow developer to whitelist which codes should trigger the GET requests associated with a given configured mutation request (X-POST, X-DELETE, etc).
- Allow developer to pass a certain header to indicate mutation failure.
I'm not familiar with HTTP spec, so I don't know if I'm missing any important nuances.