Commit b869f4e7 by Qiang Xue

form wip

parent e7c1777a
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
attributes: attributes attributes: attributes
}); });
bindAttributes(attributes); bindAttributes($form, attributes);
/** /**
* Clean up error status when resetting the form. * Clean up error status when resetting the form.
...@@ -101,10 +101,9 @@ ...@@ -101,10 +101,9 @@
$form.bind('reset', resetForm); $form.bind('reset', resetForm);
if (settings.validateOnSubmit) { if (settings.validateOnSubmit) {
$form.on('mouseup keyup', ':submit', function () { $form.on('mouseup.yiiActiveForm keyup.yiiActiveForm', ':submit', function () {
$form.data('submitObject', $(this)); $form.data('submitObject', $(this));
}); });
var validated = false;
$form.submit(submitForm); $form.submit(submitForm);
} }
}); });
...@@ -159,10 +158,11 @@ ...@@ -159,10 +158,11 @@
} }
}; };
var bindAttributes = function (attributes) { var bindAttributes = function ($form, attributes) {
$.each(attributes, function (i, attribute) { $.each(attributes, function (i, attribute) {
if (this.validateOnChange) { var $input = findInput($form, attribute);
$form.find(this.inputSelector).change(function () { if (attribute.validateOnChange) {
$input.change(function () {
validateAttribute(attribute, false); validateAttribute(attribute, false);
}).blur(function () { }).blur(function () {
if (attribute.status !== 2 && attribute.status !== 3) { if (attribute.status !== 2 && attribute.status !== 3) {
...@@ -170,9 +170,9 @@ ...@@ -170,9 +170,9 @@
} }
}); });
} }
if (this.validateOnType) { if (attribute.validateOnType) {
$form.find(this.inputSelector).keyup(function () { $input.keyup(function () {
if (attribute.value !== getAFValue($(this))) { if (attribute.value !== getInputValue($input)) {
validateAttribute(attribute, false); validateAttribute(attribute, false);
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment