luci-base: cbi: only spawn dynlist sub-comboboxes if choices are available
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 10 Feb 2016 17:23:39 +0000 (18:23 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 10 Feb 2016 17:23:39 +0000 (18:23 +0100)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
modules/luci-base/htdocs/luci-static/resources/cbi.js

index b27c564922cfd6f4b3dd0ca73d31422053b332db..a1491cc6635a36878acb8eea16648cbcc4a2fe96 100644 (file)
@@ -550,10 +550,14 @@ function cbi_init() {
 
        for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
                var choices = JSON.parse(node.getAttribute('data-dynlist'));
-               var options = {};
+               var options = null;
 
-               for (var j = 0; j < choices[0].length; j++)
-                       options[choices[0][j]] = choices[1][j];
+               if (choices[0] && choices[0].length) {
+                       options = {};
+
+                       for (var j = 0; j < choices[0].length; j++)
+                               options[choices[0][j]] = choices[1][j];
+               }
 
                cbi_dynlist_init(node, choices[2], choices[3], options);
        }