diff --git a/dist/angular-validator.js b/dist/angular-validator.js index 4bd5578..a788933 100644 --- a/dist/angular-validator.js +++ b/dist/angular-validator.js @@ -33,6 +33,11 @@ angular.module('angularValidator').directive('angularValidator', } }); + // Watch form length to add watches into new form elements + scope.$watch(function(){return DOMForm.length;}, function(){ + setupWatches(DOMForm); + }); + // Setup watches on all form fields setupWatches(DOMForm); @@ -51,6 +56,12 @@ angular.module('angularValidator').directive('angularValidator', // Setup $watch on a single formfield function setupWatch(elementToWatch) { + //Prevent to re-watch the element + if (elementToWatch.isWatchedByValidator){ + return; + } + elementToWatch.isWatchedByValidator = true; + // If element is set to validate on blur then update the element on blur if ("validate-on" in elementToWatch.attributes && elementToWatch.attributes["validate-on"].value === "blur") { angular.element(elementToWatch).on('blur', function() { diff --git a/dist/angular-validator.min.js b/dist/angular-validator.min.js index f49c07e..167c8e9 100644 --- a/dist/angular-validator.min.js +++ b/dist/angular-validator.min.js @@ -1 +1 @@ -angular.module("angularValidator",[]),angular.module("angularValidator").directive("angularValidator",function(){return{restrict:"A",link:function(a,b){function c(a){for(var b=0;b Required"},d=function(){return" Invalid"};if(b.name in n){var e=n[b.name];if(e.$dirty||a[b.form.name].submitted){var f=j(b);f&&f.remove(),e.$error.required?angular.element(b).after("required-message"in b.attributes?i(b.attributes["required-message"].value):i(c)):e.$valid||angular.element(b).after("invalid-message"in b.attributes?i(b.attributes["invalid-message"].value):i(d))}}}function i(b){return""}function j(a){for(var b=angular.element(a).parent().children(),c=0;c Required"},d=function(){return" Invalid"};if(b.name in n){var e=n[b.name];if(e.$dirty||a[b.form.name].submitted){var f=j(b);f&&f.remove(),e.$error.required?angular.element(b).after("required-message"in b.attributes?i(b.attributes["required-message"].value):i(c)):e.$valid||angular.element(b).after("invalid-message"in b.attributes?i(b.attributes["invalid-message"].value):i(d))}}}function i(b){return""}function j(a){for(var b=angular.element(a).parent().children(),c=0;c