0

I am using jQuery's UI dialog to open a basic form. I want to submit that form 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, they the browser opens the partial view in the browser. I want it to do the form work and close the dialog.

Is there a way to do this VIA Ajax.SubmitForm or some other method.

4

2 に答える 2

0

私は理想的な解決策を見つけましたが、それを以前に解決できなかったとは信じられません。AjaxOptions の OnSuccess 関数を使用して Ajax.BeginForm を使用するだけです。

<% using (Ajax.BeginForm("Action", "Controller", new AjaxOptions { OnSuccess = "CloseDialog" })) { %>
    <%= Html.Hidden("ID", ViewData["ID"]) %>
    <input type="submit" value="Submit" />
<% } %>

function CloseDialog() {
    $("#ImageCropModal").dialog("close");
}

これは、ビューを再レンダリングせずにフォームに投稿します。フォームの投稿が成功した後、ダイアログを手動で閉じることができます。

于 2010-02-14T20:27:35.473 に答える
0

フォームの onsubmit イベントをキャプチャし、Ajax 経由でフォームを送信し、ダイアログを閉じてReturn Falseから、ブラウザーがフォームを再度送信してページ全体のポストバックを実行しないようにする必要があります。

于 2010-02-14T09:43:10.243 に答える