@model IQueryable<crudText.Models.NewsInfo>
@using crudText.Models
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script>
$(function () {
$(".delete").click(function () {
var nid = $(this).attr("nid");
alert(nid);
$.post("@Url.Action("Delete","NewsInfo")", { "id": nid }, function (data) {
if (data == "OK") {
$(this).parent().parent().remove(); //这里使用进行删除无反应
}
})
});
})
</script>
<title>Index</title>
</head>
<body>
<div>
<table border="1">
<thead>
<tr>
<th>编号</th>
<th>标题</th>
<th>分类</th>
<th>编辑</th>
<th>删除</th>
</tr>
</thead>
<tbody id="tbody">
@foreach(NewsInfo item in Model)
{
<tr>
<td>@Html.ActionLink(item.nid.ToString(),"Detial","NewsInfo",new RouteValueDictionary(new { id=item.nid}),null)</td>
<td>@item.nTitle</td>
<td>@item.NewsType.tTile</td>
<td>@Html.ActionLink("编辑","Edit","NewsInfo",new RouteValueDictionary(new {id=item.nid }),null
)</td>
<td><a href="javascript: void(0)" nid="@item.nid" class="delete">删除</a></td>
</tr>
}
</tbody>
</table>
</div>
</body>
</html>
提前获取父级对象,晕了....