luci-base: cbi: fix reverse field order after dependency change
When fields got removed and readded due to unsatisfied dependencies, they got inserted in reverse order into the dom. Fix this issue by properly passing the element index. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
parent
b50471787f
commit
808c1b77f9
1 changed files with 5 additions and 4 deletions
|
@ -506,10 +506,11 @@ function cbi_init() {
|
|||
var nodes = document.querySelectorAll('[data-depends]');
|
||||
|
||||
for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
|
||||
var deps = JSON.parse(node.getAttribute('data-depends'));
|
||||
if (deps.length > 0) {
|
||||
for (var alt = 0; alt < deps.length; alt++) {
|
||||
cbi_d_add(node, deps[alt], i);
|
||||
var index = parseInt(node.getAttribute('data-index'), 10);
|
||||
var depends = JSON.parse(node.getAttribute('data-depends'));
|
||||
if (!isNaN(index) && depends.length > 0) {
|
||||
for (var alt = 0; alt < depends.length; alt++) {
|
||||
cbi_d_add(node, depends[alt], index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue