0

I am using JQuery's UI dialog to open a form. My attempt is to submit and close the dialog. I am having trouble.

The parent window opens the dialog (which contains a partial view) from click and form is submitted, for the first time, data is saved in DB. But if I click to open the dialog again and submit, there are 2 data rows saved in DB with the same value.

My code is below:

$('#newFileDialog').dialog('destroy');$('#newFileDialog').remove();

Is there something wrong with this code?

Your help is appreciated.

UPDATE:

Partial view:

@using(Html.BeginForm("New", "File", new {}, FormMethod.Post, new { Id = "newFileForm" }  ))
{    
   @Html.ValidationSummary()    
   @Html.RenderHTML(
        new TabContainerViewModel(
                new TabViewModel { Name = "File", ViewName = "Common", Model = Model, Visible = true},
                new TabViewModel { Name = "Permission", ViewName = string.Empty, Visible = true}
            ) { Id = "createFileTabs", Visible = true })    
   @Html.SubmitButton("Send")
}
@{ Html.JQueryAjaxForm("newFileForm", "containerComponentContent", string.Empty, "$('#newFileDialog').dialog('destroy');$('#newFileDialog').remove();showMessagebox('New File added');"); }
4

3 回答 3

0

$form.reset()关闭模式后,您必须在再次使用之前重置表单(即)。

于 2012-10-31T09:48:32.090 回答
0

我找到了解决方案。原因是因为现场活动。所以,提交后,我调用 die 事件,如下:

$('#form').die('click')

它有效!

于 2012-11-06T13:48:58.387 回答
0

请提供您的部分视图代码。

我认为您的表单提交了 2 次。使用 firebug 检查您生成的请求。

于 2012-10-31T10:44:39.933 回答