1

Currently I am using Form.Validator from Mootools 1.2.5 and Mootools-More 1.2.5, but i am having a hard time validating an Element's input when dynamically injected into the DOM after ondomready. I was wonder if there's a way to attach Form.Validator's functionalities to the newly inject Elements?


UPDATE:

Using what @Dimitar suggested i was able to fix the issue. I use the build in function getFields to repopulate/attach events to the dynamic Elements. formValidatorObj.watchFields(formValidatorObj.getFields()); Hope this will help some Mootooler's in the future!

KJYe.Name
  • 16,969
  • 5
  • 48
  • 63

1 Answers1

1

i am not a big -more users but looking at the source code on github, this seems like a good guess:

https://github.com/mootools/mootools-more/blob/master/Source/Forms/Form.Validator.js#L161

i guess you can pass any element - dynamically created or otherwise.

formValidatorObj.watchFields([someElsCollection]); // or from form.getElements or whatever.

// dynamically add a new field...
formValidatorObj.watchFields([new Element("input.required[value=John]").inject(formValidatorObj.element, "top")]);
Dimitar Christoff
  • 26,147
  • 8
  • 50
  • 69
  • +1 this works great. I use the build in function `getFields` to repopulate/attach events to the dynamic Elements. `formValidatorObj.watchFields(formValidatorObj.getFields());` Hope this will help some Mootooler's in the future thanks @Dimitar – KJYe.Name Apr 21 '11 at 13:01