Fixed selects to keep values after network change
This commit is contained in:
@@ -300,6 +300,7 @@
|
||||
$("#network_id").select2({placeholder: ""});
|
||||
$("#pop_id").select2({placeholder: "", allowClear: true,});
|
||||
$("#type_id").select2({placeholder: ""});
|
||||
$("#networksection_id").select2({placeholder: "", allowClear: true,});
|
||||
|
||||
// disable mousewheel on input number field when in focus
|
||||
$('form').on('focus', 'input[type=number]', function (e) {
|
||||
@@ -325,14 +326,18 @@
|
||||
function(success) {
|
||||
if(success.status == "OK") {
|
||||
//console.log(success);
|
||||
pops = success.result.pops;
|
||||
var pops = success.result.pops;
|
||||
if(typeof pops !== 'object' || pops === null) {
|
||||
return true;
|
||||
}
|
||||
var selected = $("#pop_id option:selected").val();
|
||||
$("#pop_id option:gt(0)").remove();
|
||||
for(var pop_id in pops) {
|
||||
$("#pop_id").append($("<option></option>").attr("value", pop_id).text(pops[pop_id]));
|
||||
}
|
||||
if(selected) {
|
||||
$("#pop_id").val(selected);
|
||||
}
|
||||
}
|
||||
},
|
||||
'json'
|
||||
@@ -352,13 +357,18 @@
|
||||
},
|
||||
function(success) {
|
||||
if(success.status == "OK") {
|
||||
sections = success.result.sections;
|
||||
var sections = success.result.sections;
|
||||
if(typeof sections !== 'object' || sections === null) {
|
||||
return true;
|
||||
}
|
||||
var selected = $("#networksection_id option:selected").val();
|
||||
$("#networksection_id option:gt(0)").remove();
|
||||
for(var section_id in sections) {
|
||||
$("#networksection_id").append($("<option></option>").attr("value", pop_id).text(sections[section_id]));
|
||||
$("#networksection_id").append($("<option></option>").attr("value", section_id).text(sections[section_id]));
|
||||
}
|
||||
console.log("selected: " + selected);
|
||||
if(selected) {
|
||||
$("#networksection_id").val(selected);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -387,11 +397,15 @@
|
||||
return true;
|
||||
}
|
||||
types.forEach(function(type) {
|
||||
var selected = $("#" + type + "_id option:selected").val();
|
||||
$("#" + type + "_id").empty();
|
||||
$("#" + type + "_id").append($("<option></option>"));
|
||||
for(var perm_id in perms[type]) {
|
||||
$("#" + type + "_id").append($("<option></option>").attr("value", perm_id).text(perms[type][perm_id]));
|
||||
}
|
||||
if(selected) {
|
||||
$("#" + type + "_id").val(selected);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user