clear-input recherche
This commit is contained in:
@@ -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 ////////////
|
||||
|
||||
Reference in New Issue
Block a user