jquery - 递归附加“提交”使用 ajax 处理表单?
我正在使用一个模态插件(colorbox),它有一个选项“onComplete
”。我可以执行以下操作来实现我想要的部分效果(这只是“onComplete
”选项):
onComplete: function(){
$('.ajaxform').ajaxForm({
success: function(responseText){
$.colorbox({html:responseText});
}
});
}
原因是通过ajax加载的模式包含一个表单。该表单使用 ajaxForm()
提交,并且模式会更改以反映 responseText
。它效果很好(对于第一种形式)。但问题是我连续有几个表格。附加“ajaxForm()”并仍然在许多表单中使用 $.colorbox({html:responseText})
的好方法是什么?我想对未指定数量的表单执行此操作(换句话说,在代码中我无法编写它认为我有 4 个表单,因为也许我以后会有 5 个或 3 个表单或其他表单)
I'm using a modal plugin (colorbox) that has an option "onComplete
". I can do the following to achieve part of the effect I'm going for (this is just the "onComplete
" option):
onComplete: function(){
$('.ajaxform').ajaxForm({
success: function(responseText){
$.colorbox({html:responseText});
}
});
}
The reason is that the modal loaded through ajax contains a form. That form uses ajaxForm()
to submit and the modal is changed to reflect the responseText
. It works great (for the first form). But the problem is that I have several forms in a row. What's a good way to attach the 'ajaxForm()' and still use the $.colorbox({html:responseText})
to many forms? I'd like to do this for an unspecified number of forms (in other words, in the code I can't write it thinking I have 4 forms, because maybe I'll later have 5 or 3 or something)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将“onComplete”定义为独立函数即可:
Just define your "onComplete" as a standalone function: