Skip to content

Commit

Permalink
form-javascript MDL-24024 Fixed bug with mforms JavaScript whereby de…
Browse files Browse the repository at this point in the history
…pendencies on radio buttons were constantly returning true
  • Loading branch information
Sam Hemelryk committed Sep 13, 2010
1 parent c72b990 commit e2620b9
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions lib/form/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
hide = false;
checkfunction = '_dependency_'+condition;
if (Y.Lang.isFunction(this[checkfunction])) {
result = this[checkfunction].apply(this, [this._depElements[dependon], value]);
result = this[checkfunction].apply(this, [this._depElements[dependon], value, e]);
} else {
result = this._dependency_default(this._depElements[dependon], value);
result = this._dependency_default(this._depElements[dependon], value, e);
}
lock = result.lock || false;
hide = result.hide || false;
Expand Down Expand Up @@ -223,7 +223,10 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
_dependency_notchecked : function(elements, value) {
var lock = false;
elements.each(function(){
lock = lock || !this.get('checked');
if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
return;
}
lock = lock || !Y.Node.getDOMNode(this).checked;
});
return {
lock : lock,
Expand All @@ -233,7 +236,10 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
_dependency_checked : function(elements, value) {
var lock = false;
elements.each(function(){
lock = lock || this.get('checked');
if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
return;
}
lock = lock || Y.Node.getDOMNode(this).checked;
});
return {
lock : lock,
Expand All @@ -253,6 +259,9 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
_dependency_eq : function(elements, value) {
var lock = false;
elements.each(function(){
if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
return;
}
lock = lock || this.get('value') == value;
});
return {
Expand All @@ -266,9 +275,12 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
hide : true
}
},
_dependency_default : function(elements, value) {
_dependency_default : function(elements, value, ev) {
var lock = false;
elements.each(function(){
if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
return;
}
lock = lock || this.get('value') != value;
});
return {
Expand Down

0 comments on commit e2620b9

Please sign in to comment.