summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2016-01-18 18:59:14 +0100
committerJo-Philipp Wich <jow@openwrt.org>2016-01-18 18:59:19 +0100
commit808c1b77f9008bc9f4a760ea0629b3fd4e49fbcb (patch)
tree2d85cb6e89133e5610d189d9a5bc5b4c7099be05 /modules/luci-base/htdocs/luci-static
parentb50471787feb9c04b365ff239aee8f39eadc236b (diff)
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>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/cbi.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index 81cc65778..8bf94a6c5 100644
--- a/modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js
@@ -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);
}
}
}