df
This commit is contained in:
parent
07791158a8
commit
33486b5329
100
Js/fonctions.js
100
Js/fonctions.js
|
|
@ -47668,16 +47668,28 @@ function formAjoutTableRef() {
|
|||
success: function(data) {
|
||||
$('#div_maj_table').html(data);
|
||||
|
||||
// On nettoie et on initialise tous les selects du formulaire
|
||||
actualiserSelectPicker('#div_maj_table .selectpicker');
|
||||
// 1. On initialise tous les selects du nouveau formulaire
|
||||
// On ne demande PAS le focus ici (paramètre false) pour ne pas forcer l'ouverture du premier select
|
||||
actualiserSelectPicker('#div_maj_table .selectpicker', false);
|
||||
|
||||
// Init composants
|
||||
$(".datepicker").datepicker({ autoclose: true, format: 'dd/mm/yyyy' });
|
||||
// 2. Initialisation des autres composants
|
||||
const formatD = (codeLangue === "en_US") ? 'mm/dd/yyyy' : 'dd/mm/yyyy';
|
||||
$(".datepicker").datepicker({
|
||||
autoclose: true,
|
||||
format: formatD
|
||||
});
|
||||
|
||||
// Focus
|
||||
setTimeout(() => {
|
||||
$('#div_maj_table input:not([type="hidden"]), #div_maj_table select').first().focus();
|
||||
}, 100);
|
||||
// 3. Focus intelligent sur le PREMIER champ du formulaire
|
||||
setTimeout(function() {
|
||||
var $firstField = $('#div_maj_table').find('input:not([type="hidden"]), select').first();
|
||||
|
||||
// Si le premier champ est un selectpicker, on utilise sa méthode focus dédiée
|
||||
if ($firstField.hasClass('selectpicker')) {
|
||||
$firstField.selectpicker('focus');
|
||||
} else {
|
||||
$firstField.focus();
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -47685,23 +47697,19 @@ function formAjoutTableRef() {
|
|||
// Filtrer la liste des villes par pays
|
||||
function filtreVilleParPays() {
|
||||
const $selectVille = $('#codeVille');
|
||||
const codePays = $('#codePays').val();
|
||||
|
||||
if (!codePays) return;
|
||||
const racineWeb = $("#racineWeb").val();
|
||||
|
||||
$.ajax({
|
||||
url: $("#racineWeb").val() + "Ajaxfiltrevilleparpays/",
|
||||
url: racineWeb + "Ajaxfiltrevilleparpays/",
|
||||
type: 'post',
|
||||
data: { codePays: codePays },
|
||||
data: { codePays: $('#codePays').val() },
|
||||
success: function(htmlOptions) {
|
||||
// On remplace le contenu
|
||||
// Injection des options (venant du PHP liste_options modifiée)
|
||||
$selectVille.html(htmlOptions);
|
||||
|
||||
// On force la désélection pour que le placeholder s'affiche
|
||||
$selectVille.val('');
|
||||
|
||||
// On appelle la fonction de sécurité
|
||||
actualiserSelectPicker('#codeVille');
|
||||
// Initialise, donne le focus et ouvre le menu des villes
|
||||
actualiserSelectPicker('#codeVille', true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -47772,19 +47780,30 @@ function formModifTableRef($idData) {
|
|||
success: function(data) {
|
||||
$('#div_maj_table').html(data);
|
||||
|
||||
// On nettoie et on initialise tous les selects du formulaire
|
||||
actualiserSelectPicker('#div_maj_table .selectpicker');
|
||||
// 1. On initialise tous les selects du nouveau formulaire
|
||||
// On ne demande PAS le focus ici (paramètre false) pour ne pas forcer l'ouverture du premier select
|
||||
actualiserSelectPicker('#div_maj_table .selectpicker', false);
|
||||
|
||||
// Initialisation des composants
|
||||
$(".datepicker").datepicker({ autoclose: true, format: 'dd/mm/yyyy' });
|
||||
// 2. Initialisation des autres composants
|
||||
const formatD = (codeLangue === "en_US") ? 'mm/dd/yyyy' : 'dd/mm/yyyy';
|
||||
$(".datepicker").datepicker({
|
||||
autoclose: true,
|
||||
format: formatD
|
||||
});
|
||||
|
||||
if (typeof stylechampsRequis === "function") stylechampsRequis();
|
||||
|
||||
// Focus intelligent
|
||||
setTimeout(function() {
|
||||
var $firstInput = $('#div_maj_table').find('input:not([type="hidden"]), select').first();
|
||||
$firstInput.focus();
|
||||
}, 200);
|
||||
// 3. Focus intelligent sur le PREMIER champ du formulaire
|
||||
setTimeout(function() {
|
||||
var $firstField = $('#div_maj_table').find('input:not([type="hidden"]), select').first();
|
||||
|
||||
// Si le premier champ est un selectpicker, on utilise sa méthode focus dédiée
|
||||
if ($firstField.hasClass('selectpicker')) {
|
||||
$firstField.selectpicker('focus');
|
||||
} else {
|
||||
$firstField.focus();
|
||||
}
|
||||
}, 200);
|
||||
},
|
||||
error: function(xhr) {
|
||||
toastr.error("Erreur de chargement du formulaire");
|
||||
|
|
@ -91646,25 +91665,25 @@ function initDataTableReference(selector, exportTitle = 'Export_Donnees') {
|
|||
return table;
|
||||
}
|
||||
|
||||
function actualiserSelectPicker(selector) {
|
||||
/**
|
||||
* Initialise, rafraîchit et ouvre le SelectPicker
|
||||
* @param {string} selector - Le sélecteur du select
|
||||
* @param {boolean} donnerFocus - Si true, donne le focus et ouvre le menu
|
||||
*/
|
||||
function actualiserSelectPicker(selector, donnerFocus = false) {
|
||||
$(selector).each(function() {
|
||||
const $el = $(this);
|
||||
const lang = $("#codeLangue").val();
|
||||
const txtDefault = (lang === 'en_US') ? "-- Select --" : "-- Sélectionner --";
|
||||
|
||||
// 1. ON DÉTRUIT TOUT : On supprime l'instance et l'interface visuelle existante
|
||||
// 1. Nettoyage anti-doublon (Destruction complète)
|
||||
if ($el.data('selectpicker')) {
|
||||
$el.selectpicker('destroy');
|
||||
}
|
||||
|
||||
// On supprime manuellement les restes du DOM au cas où
|
||||
$el.siblings('.bootstrap-select').remove();
|
||||
|
||||
// 2. NETTOYAGE DES ATTRIBUTS : On vide tout ce qui peut servir de titre
|
||||
$el.removeAttr('title').prop('title', '');
|
||||
$el.attr('placeholder', '');
|
||||
|
||||
// 3. RÉ-INITIALISATION PROPRE
|
||||
// 2. Initialisation Neutral Pro
|
||||
$el.selectpicker({
|
||||
liveSearch: true,
|
||||
style: 'btn-white border-2 border-start-0 fw-bold',
|
||||
|
|
@ -91675,7 +91694,14 @@ function actualiserSelectPicker(selector) {
|
|||
liveSearchPlaceholder: (lang === 'en_US') ? "Search..." : "Rechercher..."
|
||||
});
|
||||
|
||||
// 4. Force l'affichage du texte par défaut
|
||||
$el.selectpicker('val', '');
|
||||
// 3. Focus et Ouverture automatique
|
||||
if (donnerFocus) {
|
||||
setTimeout(() => {
|
||||
// Donne le focus au composant
|
||||
$el.selectpicker('focus');
|
||||
// Ouvre le menu déroulant immédiatement
|
||||
$el.selectpicker('toggle');
|
||||
}, 150); // Délai légèrement augmenté pour garantir l'ouverture
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user