Don't validate dependencies for fields which are not part of the form
authorSteven Barth <steven@midlink.org>
Wed, 17 Sep 2008 12:07:09 +0000 (12:07 +0000)
committerSteven Barth <steven@midlink.org>
Wed, 17 Sep 2008 12:07:09 +0000 (12:07 +0000)
libs/cbi/htdocs/luci-static/resources/cbi.js

index f70818e16e1a8c503ba67f3548efdcc665f9c636..33a328cff6f227c0b1fdd213719d6432882068fe 100644 (file)
@@ -24,11 +24,13 @@ function cbi_d_add(field, dep, next) {
        }
 }
 
-function cbi_d_value(target) {
+function cbi_d_checkvalue(target, ref) {
        var t = document.getElementById(target);
        var value
        
-       if (!t || !t.value) {
+       if (!t) {
+               return true
+       } else if (!t.value) {
                value = "";
        } else {
                value = t.value;
@@ -38,14 +40,14 @@ function cbi_d_value(target) {
                }
        }
        
-       return value
+       return (value == ref)
 }
 
 function cbi_d_check(deps) {
        for (var i=0; i<deps.length; i++) {
                var istat = true
                for (var j in deps[i]) {
-                       istat = (istat && cbi_d_value(j) == deps[i][j])
+                       istat = (istat && cbi_d_checkvalue(j, deps[i][j]))
                }
                if (istat) {
                        return true