Skip to content

Commit b9ed261

Browse files
committed
Removed requirement of changing "ng-submit" to "on-submit". closes #1
1 parent 626ead2 commit b9ed261

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ Make sure CSS for Bootstrap is also included in your application. Read the [docs
6363
var myApp = angular.module("foo", ["bootstrap.angular.validation", "other-foo-depenency"]);
6464
```
6565

66-
### 4. HTML view change
67-
68-
Change all your `ng-submit` to `on-submit` in all your `<form>` tags (Fix for this change coming soon)
69-
7066
### Now Rock!!
7167

7268
Basic Bootstrap validation has enabled in your forms. No further setup and no alternation required. Try submitting a

dist/bootstrap-angular-validation.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/directives/form.directive.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ angular.module("bootstrap.angular.validation").directive("form", ["$parse", "$ro
1818
restrict: "E",
1919
require: "form",
2020
priority: 1000, // Setting a higher priority so that, this directive compiles first.
21-
compile: function($formElement) {
21+
compile: function($formElement, $formAttributes) {
2222
// Disable HTML5 validation display
2323
$formElement.attr("novalidate", "novalidate");
2424
bsValidationService.addDirective($formElement);
@@ -41,6 +41,13 @@ angular.module("bootstrap.angular.validation").directive("form", ["$parse", "$ro
4141
bsValidationService.addToNgIncludedURLs(src);
4242
}
4343

44+
var ngSubmit = $formAttributes.ngSubmit;
45+
/*
46+
* Removing ngSubmit attribute if any since ngSubmit by default doesn't respects the validation errors
47+
* on the input fields.
48+
*/
49+
delete $formAttributes.ngSubmit;
50+
4451
var preLinkFunction = function($scope, formElement, $attr, formController) {
4552
// Expose a method to manually trigger the validation
4653
formController.$validate = function() {
@@ -65,11 +72,8 @@ angular.module("bootstrap.angular.validation").directive("form", ["$parse", "$ro
6572
return false;
6673
}
6774

68-
// Do not show error once the form gets submitted
69-
$scope.formSubmissionAttempted = false;
70-
71-
// Parse the handler of on-submit & execute it
72-
var submitHandler = $parse($attr.onSubmit);
75+
// Parse the handler of ng-submit & execute it
76+
var submitHandler = $parse(ngSubmit);
7377
$scope.$apply(function() {
7478
submitHandler($scope, {$event: e});
7579
$scope.formSubmissionAttempted = false;

0 commit comments

Comments
 (0)