MooTools 表单请求在提交后恢复值
我有一个 MooTools 表单请求给我带来了问题。
提交表单后,这些值将更改回生成表单时的值。
var formRequest = new Form.Request(myFormValidator, dialogBox, {
onSend: function(){
dialogBox.setStyle('display','block');
dialogBox.fade(1);
dialogBox.set('html','Saving');
},
onSuccess: function(response) {
dialogBox.setStyle('display','block');
dialogBox.fade(1);
}
});
I have a MooTools form request that is causing problems for me.
When the form is submitted, the values change back to the values they were when the form was generated.
var formRequest = new Form.Request(myFormValidator, dialogBox, {
onSend: function(){
dialogBox.setStyle('display','block');
dialogBox.fade(1);
dialogBox.set('html','Saving');
},
onSuccess: function(response) {
dialogBox.setStyle('display','block');
dialogBox.fade(1);
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案
在更彻底地搜索文档之后,我发现表单默认会自行重置。去算算吧。有一个文字值
resetForm
需要设置为false
。解释
默认值似乎违反直觉,至少在编辑表单的上下文中是这样。当您对记录进行更改并保存时,您会希望所做的更改保留在屏幕上,而不是更改回来。
表单字段行为示例(resetForm:true)
表单字段行为示例(resetForm:false)
开发者的初衷
那么为什么会默认清除表单呢?我能理解它的唯一方法是在快速输入表格的上下文中。填写完表格后,它会清除,以便您可以快速输入另一条记录。
表单字段行为示例 (resetForm:true)
The Solution
After searching through the documentation a little more thoroughly, I found the form resets itself by default. Go figure. There is a literal value
resetForm
that needs to be set tofalse
.The Explanation
The default seems counter-intuitive, at least in the context of an edit form. When you make changes to a record and save it, you would expect your changes to stay on screen, not change back.
Example Form Field Behavior (resetForm:true)
Example Form Field Behavior (resetForm:false)
The Original Intention of the Developers
So why is the default to clear the form? The only way I can make sense of it is in the context of a quick-entry form. After you fill out the form it would clear so you can enter another record quickly.
Example Form Field Behavior (resetForm:true)