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

时间:2010-08-09 16:44:05

标签: javascript jquery forms dialog modal-dialog

我一直在努力做到以下几点:

  • 表单在jQuery Dialog中显示<​​/ li>
  • 提交表单时,应关闭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'。

请帮忙吗?

3 个答案:

答案 0 :(得分:1)

您应该尝试.remove()

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

答案 1 :(得分:0)

来自jQuery文档...

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

这可能会成功。

答案 2 :(得分:0)

我认为你应该这样做

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