jQuery Form 插件 - 如何使 ajaxForm() “实时”?
因此,我将“编辑”表单转换为 ajaxForm,其中包含以下内容:
$('#reviewForm').ajaxForm({
success: function (response) {
$('#bookReview').html(response);
}
});
这将返回相同的表单,如有必要,可以再次编辑该表单。然而,第二个表单提交不再附加 ajaxForm(),这是有道理的。
我如何确保这个表单始终是 ajaxForm,无论发生了多少次提交,类似于 live() 函数的工作原理?
So I'm turning an "edit" form into an ajaxForm with the following:
$('#reviewForm').ajaxForm({
success: function (response) {
$('#bookReview').html(response);
}
});
This returns the same form, that can be edited again, if necessary. The second form submission, however, no longer has the ajaxForm() attached to it, which makes sense.
How do I make sure this form is always an ajaxForm, no matter how many submissions have taken place, similar to how the live() function works?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
稍微修改了 ajaxSubmit 的示例,来自 http://jquery.malsup.com/form/#api 。
Sligtly modified example for ajaxSubmit from http://jquery.malsup.com/form/#api.
来自文档:
delegation
true 要启用对事件委托的支持需要 jQuery v1.7+
From the documentation :
delegation
true to enable support for event delegation requires jQuery v1.7+
您可以在响应中包含
ajaxForm
调用,例如:或者您可以将其作为成功函数的一部分来执行:
我推荐后者。
You can either include the
ajaxForm
call in the response like:or you could do it as part of the success function:
I recommend the latter.
试试这个
try this