From 653db8ae7708f5cbc36e3c16fb5debbc3000fc1d Mon Sep 17 00:00:00 2001 From: compactbrain Date: Tue, 19 May 2015 15:27:13 +0100 Subject: [PATCH] Added in refreshElements function Added in refreshElements function that can be called after an ajax update to the form, allows new elements to be validated --- src/js/validatr.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/js/validatr.js b/src/js/validatr.js index 805355f..ae5e843 100644 --- a/src/js/validatr.js +++ b/src/js/validatr.js @@ -629,8 +629,8 @@ } }, - getElements: function (form) { - if (this.formElements) { + getElements: function (form, refresh) { + if (this.formElements && !refresh) { return this.formElements; } @@ -645,6 +645,12 @@ return elements; }, + + refreshElements: function () { + this.formElements = this.getElements(this.el, true) + .on('valid.' + 'validatr', $.proxy(validElement, this)) + .on('invalid.' + 'validatr', $.proxy(invalidElement, this)); + }, validateElement: function (element) { if (!element) {