Skip to content

Commit bec7839

Browse files
committed
Add check whether element was initialized already to LiveForm.setupHandlers
This allow calling setupHandlers method on same element more times wihthout problems (e.g. for use with Grido).
1 parent ca1fd27 commit bec7839

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

live-form-validation.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,15 @@ LiveForm.isSpecialKey = function(k) {
7474
* YOU CAN CHANGE these handlers (ie. to use jQuery events instead)
7575
*/
7676
LiveForm.setupHandlers = function(el) {
77-
if (this.hasClass(el, this.options.disableLiveValidationClass)) return;
77+
if (this.hasClass(el, this.options.disableLiveValidationClass))
78+
return;
79+
80+
// Check if element was already initialized
81+
if (el.getAttribute("data-lfv-initialized"))
82+
return;
83+
84+
// Remember we initialized this element so we won't do it again
85+
el.setAttribute('data-lfv-initialized', 'true');
7886

7987
var handler = function(event) {
8088
event = event || window.event;

0 commit comments

Comments
 (0)