diff --git a/assets/src/js/functions/select.js b/assets/src/js/functions/select.js index 2da53863d..67e542085 100755 --- a/assets/src/js/functions/select.js +++ b/assets/src/js/functions/select.js @@ -289,5 +289,27 @@ function initDynamicSelectInput(input) { }, width: '100%' }); + + // Rimozione delle option presenti nell'HTML per permettere l'aggiornamento dei dati via AJAX + // Rimozione per select multipli + if ($input.prop("multiple")) { + $input.on('select2:unselecting', function (e) { + let data = e.params ? e.params.data : null; + if (data) { + let option = $input.find('option[value="' + data.id + '"]'); + option.remove(); + } + }); + } + // Rimozione per select singoli + else { + $input.on('select2:selecting', function (e) { + let data = $input.selectData(); + if (data) { + let option = $input.find('option[value="' + data.id + '"]'); + option.remove(); + } + }); + } } diff --git a/modules/articoli/edit.php b/modules/articoli/edit.php index b4cbfdf31..176c01b05 100755 --- a/modules/articoli/edit.php +++ b/modules/articoli/edit.php @@ -175,7 +175,7 @@ include_once __DIR__.'/../../core.php';
- {[ "type": "select", "label": "", "name": "id_fornitore", "ajax-source": "fornitori-articolo", "select-options": $id_record]); ?>, "value":"$id_fornitore$", "help": "." ]} + {[ "type": "select", "label": "", "name": "id_fornitore", "ajax-source": "fornitori-articolo", "select-options": $id_record]); ?>, "value":"$id_fornitore$", "help": "." ]}
@@ -460,7 +460,7 @@ if (!empty($elementi)) { \ No newline at end of file +