up
This commit is contained in:
parent
34c3eb9308
commit
f4d5f2a229
@ -88,18 +88,4 @@ document.addEventListener("htmx:afterOnLoad", function (event) {
|
|||||||
|
|
||||||
// static/js/spinner.js
|
// static/js/spinner.js
|
||||||
// Écoute tous les événements HTMX et affiche/masque le spinner global
|
// Écoute tous les événements HTMX et affiche/masque le spinner global
|
||||||
document.body.addEventListener('htmx:send', () => {
|
|
||||||
const s = document.getElementById('loading-spinner');
|
|
||||||
if (s) s.style.display = 'block';
|
|
||||||
});
|
|
||||||
document.body.addEventListener('htmx:afterOnLoad', () => {
|
|
||||||
const s = document.getElementById('loading-spinner');
|
|
||||||
if (s) s.style.display = 'none';
|
|
||||||
});
|
|
||||||
// En cas d’erreur réseau
|
|
||||||
document.body.addEventListener('htmx:afterRequest', (evt) => {
|
|
||||||
if (evt.detail.xhr.status >= 400) {
|
|
||||||
const s = document.getElementById('loading-spinner');
|
|
||||||
if (s) s.style.display = 'none';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|||||||
@ -70,5 +70,25 @@
|
|||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
<script>
|
||||||
|
// static/js/spinner.js
|
||||||
|
// Écoute tous les événements HTMX et affiche/masque le spinner global
|
||||||
|
document.body.addEventListener('htmx:send', () => {
|
||||||
|
const s = document.getElementById('loading-spinner');
|
||||||
|
if (s) s.style.display = 'block';
|
||||||
|
});
|
||||||
|
document.body.addEventListener('htmx:afterOnLoad', () => {
|
||||||
|
const s = document.getElementById('loading-spinner');
|
||||||
|
if (s) s.style.display = 'none';
|
||||||
|
});
|
||||||
|
// En cas d’erreur réseau
|
||||||
|
document.body.addEventListener('htmx:afterRequest', (evt) => {
|
||||||
|
if (evt.detail.xhr.status >= 400) {
|
||||||
|
const s = document.getElementById('loading-spinner');
|
||||||
|
if (s) s.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue
Block a user