Ho 4 dependant select che vengono generate dinamicamente con jQuery getJSON
Apro il form e seleziono con jQuery le opzioni dei valori che l'utente ha salvato.
Come posso controllare LA COMPLETA ESECUZIONE della funzione change() (che utilizzo per selezionare i valori) prima di eseguire la sucessiva funzione change() ??
Ho provato 2 varianti ....
Entrambe funzionano se il server è veloce, mentre se il server è molto impegnato non tutte le opzioni vengono selezionate .... :-(
codice:
jQuery(document).ready(function() {
/*
var id_aereoporto_arrivo = function(){
setTimeout(function(){$("#id_aereoporto_arrivo").val(2).change();}, 300);
return true;
};
var id_destinazione_andata = function(){
setTimeout(function(){$("#id_destinazione_andata").val(28).change();}, 600);
return true;
};
var id_fermata_andata = function(){
setTimeout(function(){$("#id_fermata_andata").val(260).change();}, 900);
return true;
};
var id_giorno_andata = function(){
setTimeout(function(){$("#id_giorno_andata").val(47).change();}, 1200);
return true;
};
if(id_aereoporto_arrivo()){
id_destinazione_andata();
}
if(id_destinazione_andata()){
id_fermata_andata();
}
if(id_fermata_andata()){
id_giorno_andata();
}
*/
setTimeout(function(){$("#id_aereoporto_arrivo").val(2).change();}, 500);
setTimeout(function(){$("#id_destinazione_andata").val(28).change();}, 1000);
setTimeout(function(){$("#id_fermata_andata").val(260).change();}, 1500);
setTimeout(function(){$("#id_giorno_andata").val(47).change();}, 2000);
});
Grazie per un consiglio