clear-input recherche

This commit is contained in:
2025-06-05 14:31:27 +02:00
parent 69ecedae66
commit 2f21024995
5 changed files with 99 additions and 11 deletions
+32
View File
@@ -316,3 +316,35 @@ document.addEventListener("DOMContentLoaded", function () {
});
});
////////////////// end boutons media ////////////////
////////////// start croix clear input recherche ////////////
document.addEventListener("DOMContentLoaded", function () {
const input = document.getElementById("edit-combine");
const clearBtn = document.querySelector('.form-item-combine .clear-input');
const form = document.querySelector("form.views-exposed-form");
if (input && clearBtn && form) {
// Affiche la croix si contenu présent
input.addEventListener('input', () => {
clearBtn.style.display = input.value ? 'block' : 'none';
});
// Efface et soumet le formulaire
clearBtn.addEventListener('click', () => {
input.value = '';
clearBtn.style.display = 'none';
input.focus();
form.submit(); // déclenche la recherche sans rechargement manuel
});
// Affiche la croix au chargement si une valeur est déjà présente
if (input.value) {
clearBtn.style.display = 'block';
}
}
});
////////////// end croix clear input recherche ////////////