谁能告诉我为什么下面的代码不能在弹出窗口中提交表单?点击链接应在弹出窗口中提交表单
$(".myClass").click(function ()
{
var myVar = $(this).attr("rel");
//$(this).closest("form").submit();
$("#form_id"+myVar).submit(function()
{
window.open('', 'formpopup', 'width=700,height=550,resizeable,scrollbars');
this.target = 'formpopup';
});
return false;
}) 如果我去掉弹出选项,只有$(This)表单(“.closest”).submit();,它就能工作。但事实是它失败了。有什么想法/建议吗?firebug中没有js错误。
注意:目前我们不想使用模式窗口-所以请不要使用模式建议。
发布于 2012-06-07 16:28:52
你从来没有真正提交过表单。您只需将submit事件处理程序绑定到它。您可以使用submit或trigger来实际触发submit事件:
$("#form_id"+myVar).submit(function() {
window.open('', 'formpopup', 'width=700,height=550,resizeable,scrollbars');
this.target = 'formpopup';
}).submit(); //Submit the form after binding event handler对submit的注释掉调用将在事件处理程序绑定到窗体之前发生,因此它永远不会被执行。
https://stackoverflow.com/questions/10928225
复制相似问题