luci-base: cbi.js: fix handling of inverse-depends, combobox validation
[project/luci.git] / modules / luci-base / htdocs / luci-static / resources / cbi.js
index 4be917d..b819230 100644 (file)
@@ -481,8 +481,9 @@ function cbi_d_check(deps) {
                                istat = (istat && cbi_d_checkvalue(j, deps[i][j]))
                        }
                }
                                istat = (istat && cbi_d_checkvalue(j, deps[i][j]))
                        }
                }
-               if (istat) {
-                       return !reverse;
+
+               if (istat ^ reverse) {
+                       return true;
                }
        }
        return def;
                }
        }
        return def;
@@ -648,9 +649,6 @@ function cbi_combobox(id, values, def, man, focus) {
        var dt = obj.getAttribute('cbi_datatype');
        var op = obj.getAttribute('cbi_optional');
 
        var dt = obj.getAttribute('cbi_datatype');
        var op = obj.getAttribute('cbi_optional');
 
-       if (dt)
-               cbi_validate_field(sel, op == 'true', dt);
-
        if (!values[obj.value]) {
                if (obj.value == "") {
                        var optdef = document.createElement("option");
        if (!values[obj.value]) {
                if (obj.value == "") {
                        var optdef = document.createElement("option");
@@ -685,6 +683,9 @@ function cbi_combobox(id, values, def, man, focus) {
 
        obj.style.display = "none";
 
 
        obj.style.display = "none";
 
+       if (dt)
+               cbi_validate_field(sel, op == 'true', dt);
+
        cbi_bind(sel, "change", function() {
                if (sel.selectedIndex == sel.options.length - 1) {
                        obj.style.display = "inline";
        cbi_bind(sel, "change", function() {
                if (sel.selectedIndex == sel.options.length - 1) {
                        obj.style.display = "inline";