简体   繁体   English

通过javascript / jquery向表单添加字段-如何保存状态

[英]adding fields to a form via javascript / jquery - how to save state

I have a situation where i have to modify a form (to dynamically add a table) via jquery after it's been rendered / created. 我有一种情况,我必须在呈现/创建表单后通过jquery修改表单(以动态添加表)。

The problem is that when the form is submitted, and redisplayed because of errors or validation issues, I don't know of a good way to save and redisplay the data they've entered into the fields I've created dynamically. 问题在于,提交表单并由于错误或验证问题而重新显示表单时,我不知道一种保存和重新显示他们输入到动态创建的字段中的数据的好方法。

Any suggestions would be appreciated. 任何建议,将不胜感激。

Dynamically added data don't differ from the static added ones. 动态添加的数据与静态添加的数据没有区别。 You have to use 'validate()' method to prevent submitting and rendering the html-code with errors, in this case user will see the dynamically added data. 您必须使用“ validate()”方法来防止提交和呈现带有错误的html代码,在这种情况下,用户将看到动态添加的数据。

您可能想要使用类似jQuery Populate的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM