如何动态添加元素到Mootools Form.Validator?
目前我正在使用 Mootools 1.2.5 和 Mootools-More 1.2.5 中的 Form.Validator,但是在 ondomready 后动态注入到 DOM 中时,我很难验证元素的输入。我想知道是否有办法将 Form.Validator 的功能附加到新注入的元素上?
更新:
使用@Dimitar的建议我能够解决这个问题。我使用内置函数 getFields 将事件重新填充/附加到动态元素。 formValidatorObj.watchFields(formValidatorObj.getFields());
希望这对将来的 Mootooler 有所帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不是一个大用户,但查看 github 上的源代码,这似乎是一个不错的猜测:
https://github.com/mootools/mootools-more/blob/master/Source/Forms/Form.Validator.js#L161
我猜您可以传递任何元素 - 动态创建或以其他方式创建。
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.