繁体   English   中英

提交表单时,jQuery UI关闭对话框

[英]jQuery UI close Dialog when form submitted

我一直在尝试执行以下操作:

  • 表单显示在jQuery对话框中
  • 提交表单后,jQuery对话框应关闭

我正在尝试以下代码:

    $('#RegisterDialog').dialog({
               autoOpen: false,
                closeOnEscape: false,
                position: 'center',
                modal: true,
                width: 600,
                buttons: {
                    "Cancel account registration": function() { 
                        $(this).dialog("close"); 
                        window.location = 'http://localhost/';
                    } 
                }
});

$(".Register").click(function() {
           $('#RegisterDialog').dialog("close"); 
           $('#RegisterDialog').hide();
});

但是,它会隐藏并再次弹出。 我也尝试过'autoClose:false'。

有什么帮助吗?

您应该尝试.remove()

这将删除该元素,并且不会再次弹出。

从jQuery文档...

.dialog( "destroy" ) 
// Remove the dialog functionality completely. This will return the element back to its pre-init state.

这可能会成功。

我想你应该这样

$(".Register").click(function() {
           $('#RegisterDialog').dialog("close"); 
           //$('#RegisterDialog').hide(); --> no need to call this
});

暂无
暂无

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

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