vdf
This commit is contained in:
parent
5b17009dea
commit
44e281ad6e
|
|
@ -47692,35 +47692,21 @@ function filtreVilleParPays() {
|
|||
url: racineWeb + "Ajaxfiltrevilleparpays/",
|
||||
type: 'post',
|
||||
data: { codePays: codePays },
|
||||
beforeSend: function() {
|
||||
// Étape 1 : Détruire le plugin sur l'ancien select pour éviter les doublons visuels
|
||||
$divVille.find('.selectpicker').selectpicker('destroy');
|
||||
$divVille.css('opacity', '0.5');
|
||||
},
|
||||
success: function(data) {
|
||||
// Étape 2 : Remplacer le contenu HTML (le nouveau <select> arrive du PHP)
|
||||
// Étape radicale : on vide et on nettoie avant l'injection
|
||||
$divVille.find('.selectpicker').selectpicker('destroy');
|
||||
$divVille.empty();
|
||||
|
||||
// Injection du nouveau HTML (qui doit contenir le <select>)
|
||||
$divVille.html(data);
|
||||
|
||||
// Étape 3 : Identifier le nouveau select et le reconstruire proprement
|
||||
const $newSelect = $divVille.find('select');
|
||||
|
||||
// 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%',
|
||||
size: 8
|
||||
});
|
||||
|
||||
// Étape 4 : Rafraîchissement forcé
|
||||
$newSelect.selectpicker('refresh');
|
||||
},
|
||||
complete: function() {
|
||||
$divVille.css('opacity', '1');
|
||||
// Appel de la fonction de reconstruction globale
|
||||
rafraichirSelectPicker('#div_ville');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Filtrer la liste des localités par pays et par ville
|
||||
function filtreLocaliteParVille(){
|
||||
var codePays = $('#codePays').val(),
|
||||
|
|
@ -91656,4 +91642,31 @@ function initDataTableReference(selector, exportTitle = 'Export_Donnees') {
|
|||
|
||||
table.buttons().container().appendTo('#table-buttons');
|
||||
return table;
|
||||
}
|
||||
|
||||
function rafraichirSelectPicker(selecteurDiv) {
|
||||
const $container = $(selecteurDiv);
|
||||
|
||||
// 1. Détruire toute instance existante dans ce conteneur
|
||||
$container.find('.selectpicker').selectpicker('destroy');
|
||||
|
||||
// 2. Supprimer manuellement les éléments résiduels (les div .bootstrap-select)
|
||||
$container.find('.bootstrap-select').remove();
|
||||
|
||||
// 3. Initialiser le nouveau select injecté
|
||||
const $newSelect = $container.find('select');
|
||||
|
||||
if ($newSelect.length > 0) {
|
||||
$newSelect.selectpicker({
|
||||
liveSearch: true,
|
||||
style: 'btn-white border-2 border-start-0 fw-bold',
|
||||
width: '100%',
|
||||
size: 8,
|
||||
noneSelectedText: $("#codeLangue").val() === 'en_US' ? '-- Select --' : '-- Sélectionner --'
|
||||
});
|
||||
|
||||
// 4. Forcer le rendu
|
||||
$newSelect.selectpicker('refresh');
|
||||
$newSelect.selectpicker('render');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user