Fix show/hide combo when next combo has no item inside.

This commit is contained in:
Laurent Destailleur 2021-09-17 19:38:55 +02:00
parent 68a391b395
commit b1c6a6e8d1

View File

@ -918,10 +918,17 @@ class FormTicket
if (arraynotparents.includes(this.value) || $(this).attr("child_id") == '.$use_multilevel.') {
$("#ticketcategory_select")[0].value = this.value;
$("#ticketcategory_select_child_id")[0].value = $(this).attr("child_id");
console.log("We choose to select "+ $("#ticketcategory_select")[0].value );
console.log("We choose to select "+ this.value);
}else{
$("#ticketcategory_select")[0].value = "";
$("#ticketcategory_select_child_id")[0].value = "";
if ($("#'.$htmlname.'_child_'.$levelid.' option").length <= 1) {
$("#ticketcategory_select")[0].value = this.value;
$("#ticketcategory_select_child_id")[0].value = $(this).attr("child_id");
console.log("We choose to select "+ this.value + " and next combo has no item, so we keep this selection");
} else {
console.log("We choose to select "+ this.value + " but next combo has some item, so we clean selected item");
$("#ticketcategory_select")[0].value = "";
$("#ticketcategory_select_child_id")[0].value = "";
}
}
console.log("We select a new value into combo child_id="+child_id);
@ -937,7 +944,8 @@ class FormTicket
/* Now we enable the next combo */
$("#'.$htmlname.'_child_'.$levelid.'").val("");
if (!arraynotparents.includes(this.value)) {
if (!arraynotparents.includes(this.value) && $("#'.$htmlname.'_child_'.$levelid.' option").length > 1) {
console.log($("#'.$htmlname.'_child_'.$levelid.' option").length);
$("#'.$htmlname.'_child_'.$levelid.'").show()
} else {
$("#'.$htmlname.'_child_'.$levelid.'").hide()