Skip to content

Commit

Permalink
Fix validate.reset method
Browse files Browse the repository at this point in the history
  • Loading branch information
hueitan committed Apr 13, 2014
1 parent d863375 commit 0a96acb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions dist/angular-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,6 @@
this.reset = function (form) {
for (var k in form) {
if (form[k].hasOwnProperty('$dirty')) {
form[k].$setViewValue(null);
form[k].$setPristine();
form[k].$setValidity(form[k].$name, false);
form[k].$render();
$scope.$broadcast(k + 'reset');
}
}
Expand Down Expand Up @@ -384,6 +380,10 @@
* Reset the validation for specific form
*/
scope.$on(ctrl.$name + 'reset', function () {
ctrl.$setViewValue(null);
ctrl.$setPristine();
ctrl.$setValidity(ctrl.$name, false);
ctrl.$render();
element.next().html('');
});

Expand Down
2 changes: 1 addition & 1 deletion dist/angular-validation.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@
* Reset the validation for specific form
*/
scope.$on(ctrl.$name + 'reset', function () {
ctrl.$setViewValue(null);
ctrl.$setPristine();
ctrl.$setValidity(ctrl.$name, false);
ctrl.$render();
element.next().html('');
});

Expand Down
4 changes: 0 additions & 4 deletions src/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,6 @@
this.reset = function (form) {
for (var k in form) {
if (form[k].hasOwnProperty('$dirty')) {
form[k].$setViewValue(null);
form[k].$setPristine();
form[k].$setValidity(form[k].$name, false);
form[k].$render();
$scope.$broadcast(k + 'reset');
}
}
Expand Down

0 comments on commit 0a96acb

Please sign in to comment.