From c5d1ab5f0c82b25348d3468bd43741b73a1b7001 Mon Sep 17 00:00:00 2001 From: compactbrain Date: Tue, 19 May 2015 15:29:12 +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..78d61d8 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; } @@ -646,6 +646,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) { throw new Error('method requires an element');