2010-08-09 35 views
0

我一直在努力做后续关闭对话框:jQuery UI的当表单提交

  • 形式得到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'。

请帮忙吗?

+0

嗯,只是一个说明。这将在文档加载时执行。这可能是一个问题吗? 当表单被执行时,它会查询到同一页面。 – aam1r 2010-08-09 19:00:12

+1

目前你有autoOpen:false,并且页面加载后不应弹出对话框。那么你如何显示你的对话框,$('#RegisterDialog')。对话框(“打开”)在哪里?触发? – ischenkodv 2011-03-03 20:27:33

回答

0

从jQuery的文档...

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

这可能做的伎俩。

0

我认为你应该做这样的

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

刚刚尝试过;不起作用。我也试过.dialog(“摧毁”),这也不起作用。它消失了一秒钟,马上回来。一些东西不断触发它回来似乎 – aam1r 2010-08-09 16:51:40

+0

然后请给予更多的细节,如果可能的话,所有的代码... – 2010-08-09 18:31:16

1

你应该尝试.remove()

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