From f5769348bf00c9e3fbe1dd483fcf7e122e75e3fd Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Sun, 23 Feb 2020 15:58:30 +0100 Subject: [PATCH] Fix selezione tecnici dopo inserimento --- add.php | 10 ++++------ assets/src/js/functions/select.js | 11 +++++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/add.php b/add.php index 666c480ca..d1a4dcceb 100755 --- a/add.php +++ b/add.php @@ -39,7 +39,7 @@ $(document).ready(function(){ cleanup_inputs(); var form = $("#custom_fields_top-add").parent().find("form").first(); - + // Campi a inizio form form.prepend($("#custom_fields_top-add").html()); @@ -53,7 +53,7 @@ $(document).ready(function(){ if (!last.length) { last = form.find(".row").eq(-2); } - + last.after($("#custom_fields_bottom-add").html()); restart_inputs(); }); @@ -72,16 +72,14 @@ $(document).ready(function(){ submitAjax(this, $form.variables, function(response) { // Selezione automatica nuovo valore per il select select = "#'.get('select').'"; - console.log($(select).val()); if ($(select).val() !== undefined) { - console.log(response.id + " | " + response.text); $(select).selectSetNew(response.id, response.text, response.data); } $form.closest("div[id^=bs-popup").modal("hide"); - + }); - + return false; }) }); diff --git a/assets/src/js/functions/select.js b/assets/src/js/functions/select.js index 31f64456f..1bee786af 100755 --- a/assets/src/js/functions/select.js +++ b/assets/src/js/functions/select.js @@ -125,7 +125,14 @@ jQuery.fn.selectReset = function (placeholder) { * Da utilizzare per l'impostazione dei select basati su richieste AJAX. */ jQuery.fn.selectSetNew = function (value, label, data) { - this.selectReset(); + // Fix selezione per valori multipli + var values = this.val(); + if (this.prop("multiple")) { + values.push(value); + } else { + this.selectReset(); + values = value; + } this.selectAdd([{ 'value': value, @@ -133,7 +140,7 @@ jQuery.fn.selectSetNew = function (value, label, data) { 'data': data, }]); - this.selectSet(value); + this.selectSet(values); return this; };