1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-22 13:26:38 +01:00

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

10
add.php
View File

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

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