Fix selezione tecnici dopo inserimento

This commit is contained in:
Thomas Zilio 2020-02-23 15:58:30 +01:00
parent 2ee58b0c19
commit f5769348bf
2 changed files with 13 additions and 8 deletions

View File

@ -72,9 +72,7 @@ $(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);
}

View File

@ -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) {
// 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;
};