HTMX error handling.
This commit is contained in:
parent
8860b981e6
commit
576caf217c
6 changed files with 24 additions and 16 deletions
|
|
@ -24,9 +24,19 @@
|
|||
{{define "footer"}}
|
||||
{{- if .CSRF}}
|
||||
<script>
|
||||
document.body.addEventListener('htmx:configRequest', (event) => {
|
||||
event.detail.parameters['csrf'] = '{{ .CSRF }}';
|
||||
document.body.addEventListener('htmx:configRequest', function(evt) {
|
||||
if (evt.detail.verb !== "get") {
|
||||
evt.detail.parameters['csrf'] = '{{ .CSRF }}';
|
||||
}
|
||||
})
|
||||
</script>
|
||||
{{end}}
|
||||
<script>
|
||||
document.body.addEventListener('htmx:beforeSwap', function(evt) {
|
||||
if (evt.detail.xhr.status >= 400){
|
||||
evt.detail.shouldSwap = true;
|
||||
evt.detail.target = htmx.find("body");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue