This commit is contained in:
KONE SOREL 2026-03-07 09:29:08 +00:00
parent ec5878d0f1
commit 5b17009dea
3 changed files with 32 additions and 20 deletions

View File

@ -47692,23 +47692,31 @@ function filtreVilleParPays() {
url: racineWeb + "Ajaxfiltrevilleparpays/",
type: 'post',
data: { codePays: codePays },
success: function(data) {
// 1. Détruire l'instance SelectPicker existante avant de vider le HTML
beforeSend: function() {
// Étape 1 : Détruire le plugin sur l'ancien select pour éviter les doublons visuels
$divVille.find('.selectpicker').selectpicker('destroy');
// 2. Injecter le nouveau contenu
$divVille.css('opacity', '0.5');
},
success: function(data) {
// Étape 2 : Remplacer le contenu HTML (le nouveau <select> arrive du PHP)
$divVille.html(data);
// 3. Ré-initialiser proprement le nouveau select
// Étape 3 : Identifier le nouveau select et le reconstruire proprement
const $newSelect = $divVille.find('select');
$newSelect.addClass('selectpicker').selectpicker({
// On s'assure qu'il a les bonnes classes
$newSelect.addClass('form-control selectpicker').selectpicker({
liveSearch: true,
style: 'btn-white border-2 border-start-0 fw-bold',
width: '100%'
width: '100%',
size: 8
});
// 4. Forcer le rafraîchissement final
// Étape 4 : Rafraîchissement forcé
$newSelect.selectpicker('refresh');
},
complete: function() {
$divVille.css('opacity', '1');
}
});
}

View File

@ -1,3 +1,6 @@
<select name="codeVille" id="codeVille" class="form-select selectpicker" data-live-search="true" required onchange="filtreLocaliteParVille();">
<?= liste_options($villes, '', false) ?>
<span class="input-group-text bg-light border-2 border-end-0"><i class="fas fa-city text-muted"></i></span>
<select name="codeVille" id="codeVille" class="form-control selectpicker" data-live-search="true" required onchange="JAVASCRIPT:filtreLocaliteParVille();">
<?= liste_options($ville,'',false) ?>
</select>

View File

@ -7,13 +7,16 @@
<div class="card-body">
<form id="formData">
<input type="hidden" id="id" name="id" value="<?= $localite['id'] ?? '' ?>">
<div class="row g-3">
<div class="col-md-4">
<label class="form-label small fw-bold text-muted required"><?= _("Nom de la Localité") ?></label>
<label class="form-label small fw-bold text-muted required"><?= _("Nom Localité") ?></label>
<div class="input-group">
<span class="input-group-text bg-light border-2 border-end-0"><i class="fas fa-map-marker-alt text-muted"></i></span>
<input class="form-control border-2 border-start-0 ps-0 majuscule"
type="text" id="libelle" name="libelle"
value="<?= $this->nettoyer($localite['libelle'] ?? '') ?>"
required autocomplete="off" autofocus>
</div>
</div>
@ -23,10 +26,9 @@
<div class="input-group">
<span class="input-group-text bg-light border-2 border-end-0"><i class="fas fa-flag text-muted"></i></span>
<select name="codePays" id="codePays"
class="form-select border-2 border-start-0 ps-0 selectpicker show-tick"
data-live-search="true"
required onchange="filtreVilleParPays();">
<?= liste_options($pays,'',false) ?>
class="form-control border-2 border-start-0 ps-0 selectpicker"
data-live-search="true" required onchange="filtreVilleParPays();">
<?= liste_options($pays, $localite['codePays'] ?? '', false) ?>
</select>
</div>
</div>
@ -36,10 +38,9 @@
<div class="input-group" id="div_ville">
<span class="input-group-text bg-light border-2 border-end-0"><i class="fas fa-city text-muted"></i></span>
<select name="codeVille" id="codeVille"
class="form-select border-2 border-start-0 ps-0 selectpicker show-tick"
data-live-search="true"
required>
<?= liste_options($ville,'',false) ?>
class="form-control border-2 border-start-0 ps-0 selectpicker"
data-live-search="true" required>
<?= liste_options($ville, $localite['codeVille'] ?? '', false) ?>
</select>
</div>
</div>