This commit is contained in:
cangui 2025-06-21 20:28:07 +02:00
parent 34c3eb9308
commit f4d5f2a229
2 changed files with 21 additions and 15 deletions

View File

@ -88,18 +88,4 @@ document.addEventListener("htmx:afterOnLoad", function (event) {
// 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 derreur 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';
}
});

View File

@ -70,5 +70,25 @@
</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 derreur 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>