luci-base:adjust the code order 917/head
authorJian Chang <aa65535@live.com>
Tue, 3 Jan 2017 11:00:53 +0000 (19:00 +0800)
committerJian Chang <aa65535@live.com>
Tue, 3 Jan 2017 11:00:53 +0000 (19:00 +0800)
The `cbi_validate_field` should be after data initialized.

Signed-off-by: Jian Chang <aa65535@live.com>
modules/luci-base/htdocs/luci-static/resources/cbi.js

index 5790e303dd3e41128179af509d5666d854334463..0ca7e264a7172f6d3aa4ba1c8672ecac9a0fe65a 100644 (file)
@@ -523,13 +523,6 @@ function cbi_init() {
                }
        }
 
-       nodes = document.querySelectorAll('[data-type]');
-
-       for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
-               cbi_validate_field(node, node.getAttribute('data-optional') === 'true',
-                                  node.getAttribute('data-type'));
-       }
-
        nodes = document.querySelectorAll('[data-choices]');
 
        for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
@@ -562,6 +555,13 @@ function cbi_init() {
                cbi_dynlist_init(node, choices[2], choices[3], options);
        }
 
+       nodes = document.querySelectorAll('[data-type]');
+
+       for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
+               cbi_validate_field(node, node.getAttribute('data-optional') === 'true',
+                                  node.getAttribute('data-type'));
+       }
+
        cbi_d_update();
 }