Fixed config page bugs

Former-commit-id: cd32facd6e679eb9a66b294d4011da8eb801fd00
This commit is contained in:
Ziver Koc 2016-01-22 20:48:29 +01:00
parent 09d59635c3
commit 5a4107f60f
4 changed files with 32 additions and 28 deletions

View file

@ -66,7 +66,7 @@
<tr>
<td>{{.getType()}}</td>
<td>{{.getDeviceData().getTimestamp()}}</td>
<td>{{.}}</td>
<td>{{.getDeviceData()}}</td>
<td>
<div class="btn-toolbar pull-right">
<button type="button" class="btn btn-default btn-xs" data-toggle="modal"
@ -204,15 +204,6 @@
var modal = $(this);
modal.find("input[type=text]").val(""); // Reset all inputs
if(button.data("id") >= 0){ // edit
modal.find("select[name=type]").val(button.data("type"));
modal.find("select[name=type]").change(); // Update dynamic inputs
$.each(button.attr(), function(name, value) {
if(name.startsWith("data-")) {
name = name.substring(5);
console.log(name, value);
modal.find("input[name="+name+"]").val(value);
}
});
modal.find("input[name=action]").val("modify_local_sensor");
modal.find("input[name=sync]").prop("checked", button.data("sync"));
}
@ -220,8 +211,17 @@
modal.find("input[name=action]").val("create_local_sensor");
modal.find("input[name=id]").val(-1);
modal.find("input[name=sync]").prop("checked", "false");
modal.find("select[name=type]").change(); // Update dynamic inputs
}
// set dynamic form data
modal.find("select[name=type]").val(button.data("type"));
modal.find("select[name=type]").change(); // Update dynamic inputs
$.each(button.attr(), function(name, value) {
if(name.startsWith("data-")) {
name = name.substring(5);
console.log(name, value);
modal.find("input[name="+name+"]").val(value);
}
});
});