我需要在部分视图中捕获chekcbox更改,呈现为bootstrap模式对话框。我尝试使用
$(".modal input:checkbox").change(function () {
$(".modal input:checkbox").attr("checked", false);
$(this).attr("checked", true);
});
没有运气。
这是观点:
@model List<MyModel>
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
<h4 class="modal-title"></h4>
</div>
@using (Html.BeginForm("DoSomething", "MyController", FormMethod.Post, new { @class = "form-horizontal", role = "form"}))
{
<div class="modal-body">
<table class="table borderless">
@for (int i = 0; i < Model.Count; i++)
{
<tr>
<td>
@Html.HiddenFor(item => item[i].Id)
</td>
<td>
@Html.CheckBoxFor(item => item[i].Checked)
</td>
<td>
@Html.TextBoxFor(item => item[i].Title, new { @style = "border: none; width: 100% " })
</td>
<td>
@Html.TextBoxFor(item => item[i].Desc, new { @style = "border: none; width: 100% " })
</td>
</tr>
}
</table>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="submit">Close</button>
</div>
}
从主视图使用actionlink调用对话框。