我刚刚获取了演示 jquery UI 对话框(模型对话框)示例 ,并尝试将其包含在我的 asp.net mvc 项目中,但我发现了一些奇怪的东西。
如果您在 jquery ui 对话框 div 标签中有内容,则默认模型绑定器在发布到服务器期间不会拾取它,因为如果从表单中删除这些元素
完整的视图代码如下。如果您在底部看到,则有对话框内容所在的部分:
<div id="dialog"
问题是在“div 对话框”内的表格中,还有许多输入映射到我的绑定数据对象字段。当我在调试期间查看我的控制器操作时,这些在发布后都是空的。
当代码位于表单元素内时,jquery ui 对话框 js 代码会在发布时将其从默认模型绑定器“范围”中删除吗?
Javascript代码:
<script type="text/javascript">
$(function() {
$("#dialog").dialog({
bgiframe: true,
autoOpen: false,
height: 500,
width: 500,
modal: true,
buttons: {
'Create an account': function() {
代码
<% using (Html.BeginForm("UpdateTester", "Applications", FormMethod.Post))
{%>
<table id="users" class="ui-widget ui-widget-content">
<thead>
<tr class="ui-widget-header ">
<th>Name</th>
<th>Email </th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type='hidden' name='peopleUpdater.person[0].c' value="1" />
<input type='hidden' name='peopleUpdater.person[0].b.Id' value="1" />
<input type='hidden' name='peopleUpdater.person[0].a[0].Id' value="1" /> John Doe
<input type='hidden' name='peopleUpdater.person[0].name' value="joe" />
</td>
<td>
john.doe@example.com
<input name='peopleUpdater.person[0].email' type='hidden' value="email" />
</td>
<td>
Locations:
<%=Model.BusinessLocations.Length %><input type="button" value="Details" id="showDetails" />
</td>
</tr>
</tbody>
</table>
</div>
<input type="submit" id="Button1" class="ui-button ui-state-default ui-corner-all" />Submit
<div id="dialog" title="Create new user">
<%=ApplicationHTMLHelper.BuildTableLocations("aa", Model.Application.BusinessLocations, true, "peopleUpdater.person[0]")%>
</div>
<% } %>