送信ボタンまたはリンクをクリックしたときに送信を実行し、同じモーダルダイアログに留まるようにする方法を作成しようとしています。私のプログラムには同じダイアログ内に2つのフォームがあり、1つは最初のフォームが送信されるまで表示されません。最初のフォームの読み込みを送信すると、同じダイアログ内にフォームが表示されます。
ロードダイアログの場合、次のコードがあります。
function loadDialog(tag, event, target) {
event.preventDefault();
var $loading = $('<img src="../../Content/assets/images/nivo-loader.gif" alt="loading" class="ui-loading-icon">');
var $url = $(tag).attr('href');
var $title = $(tag).attr('title');
var $dialog = $('<div></div>');
$dialog.empty();
$dialog
.append($loading)
.load($url)
.dialog({
autoOpen: false
, title: $title
, width: 600
, modal: true
, minHeight: 200
, show: 'fade'
, hide: 'fade'
});
});
次に、Create.cshtmlで:
@model Mvcproject.Models.MyModel
<script language="javascript" type="text/javascript">
$(function () {
$("input[type=submit]")
.button(
);
$('a.modalDlg2').live("click", function (event) { loadDialog('#modalDlg', event, '#Receipt Create'); });
/*$('input.Submit').live("click", function (event) {
e.preventDefault();
loadDialog('#modalDlg', event, '#Receipt Create');
});*/
$(".demo button").button({
icons:
{
primary: 'ui-icon-plusthick'
}
});
});
</script>
<h2>
Add line</h2>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset class="createReceipt">
<legend>User login</legend>
@if (ViewBag.Created)
{
<table class="createTable">
<tr>
<td rowspan="4">
<img src="../../Images/no_image.jpg" width="100" height="100" />
</td>
<th colspan="1">
@Html.LabelFor(model => model.User.Name)
</th>
<td colspan="5">
@Html.EditorFor(model => model.User.Name)
@Html.ValidationMessageFor(model => model.User.Name)
</td>
</tr>
<tr>
<th colspan="1">
@Html.LabelFor(model => model.User.Email)
</th>
<td colspan="5">
@Html.EditorFor(model => model.User.Email)
@Html.ValidationMessageFor(model => model.User.Email)
</td>
</tr>
<tr>
<th colspan="1">
@Html.LabelFor(model => model.User.Password)
</th>
<td colspan="5">
@Html.EditorFor(model => model.User.Password)
@Html.ValidationMessageFor(model => model.User.Password)
</td>
</tr>
<!--User picture-->
<tr>
<td>
<input type="file" value="browse" name="Browse" accept="image/gif, image/jpeg, image/jpg" />
</td>
</tr>
</table>
<p>
<input type="submit" class="Submit" value="Create" />
<buttonreceipt style="width: 150px; text-align: left">@Html.ActionLink("Create", "Create")</buttonreceipt>
</p>
}
else
{
<!-- This will be displayed when user data is submited and inserted into database-->
<table class="createTable">
<tr>
<th colspan="1">
@Html.LabelFor(model => model.User.Name)
</th>
<td colspan="5">
@Html.DisplayFor(model => model.User.Name)
</td>
</tr>
<tr>
<th colspan="1">
@Html.LabelFor(model => model.User.Email)
</th>
<td colspan="5">
@Html.DisplayFor(model => model.User.Email)
</td>
</tr>
<tr>
<td colspan="1">
<img src="@Model.User.Picture"/>
</td>
</tr>
</table>
}
</fieldset>
}
@if (!ViewBag.Created)
{
@Html.Partial("_AddUserInformation");
}
ViewBag.Createdは、ユーザーデータがデータベースに正常に挿入され、その機能がすでに実行されているかどうかに応じて、falseまたはtrueのいずれかになります。
そして、_AddUserInformation.cshtmlには、住所や国など、登録しようとしているユーザーに関するその他の情報があります...
これが私の問題をよりよく説明することを願っています。