我正在使用下面的代码创建一个模式,该模式会根据 id 弹出填充页面,然后允许您编辑位置。模态如何无法打开。有人能告诉我为什么吗?
@model IEnumerable<LocApp.Models.Location>
<table class="table table-bordered">
<thread>
<tr>
<th>Name</th>
<th>Active</th>
<th>Actions</th>
</tr>
</thread>
@foreach (var item in Model)
{
<thread>
<tr>
<td>
@Html.DisplayFor(modelItem => item.name)
</td>
<td>
@Html.DisplayFor(modelItem => item.active)
</td>
<td>
<a href="@Url.Action("Edit", "Location", new { id = item.id})" class="edit" data-target="#@item.id">Edit</a> |
@Html.ActionLink("Details", "Details", new { id = item.id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.id })
</td>
</tr>
</thread>
<div class="modal hide fade" id="@item.id" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Edit @item.name</h3>
</div>
<div class="modal-body">
</div>
</div>
}
</table>
<script>
$('a.edit').on('click', function (e) {
e.preventDefault();
var url = $(this).attr('href');
$(".modal-body").html('<iframe width="100%" height="100%" frameborder="0" scrolling="no" allowtransparency="true" src="' + url + '"></iframe>');
});
</script>
有什么我想念的吗?