私は文書のリストを持っており、レコードごとに異なるアクションが実行されています。レコードを削除するには、IDをコントローラに渡す必要があります。私は削除を実行するためにJQueryを使用します。それで私はそのレコードのIDに必要です。以下は私の見解です。jqueryを使ってレコードを削除するにはどうすればいいですか?
<script type="text/javascript">
$(function() {
$(".delete_link").live("click", function(e) {
alert("Hi");
e.preventDefault();
if (confirm("Are you sure you want to delete?")) {
$.post("/BuildDocument/DeleteBuildDocument", {need to pass id here..});
}
else {
$.post("/BuildDocument/IndexBuildDocument");
}
});
});
</script>
<div>
<div>
<h1>
List Build Document</h1>
<ul>
<%if (Model.ToList().Count > 0)
{ %>
<li>
<br />
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<th align="left">
Part No.
</th>
<th align="left">
Issue No
</th>
<th align="left">
Document template
</th>
<th align="left">
Title
</th>
<th align="center">
View
</th>
<th align="center">
Edit
</th>
<th align="center">
Delete
</th>
</tr>
<% foreach (var item in Model)
{ %>
<tr>
<td>
<%= Html.Encode(item.BldDocPartNo)%>
</td>
<td>
<%= Html.Encode(item.BldDocIssueNo)%>
</td>
<td>
<%= Html.Encode(item.BldDocDocmntTitle)%>
</td>
<td>
<%= Html.Encode(item.BldDocTitle)%>
</td>
<td align="center">
<a href='<%= Url.Action("DetailBuildDocument", "BuildDocument", new { bldDocId = item.BldDocId })%>'>
<img src="../../html/images/edit-icon.gif" alt="edit" border="0" /></a>
</td>
<td align="center">
<a href='<%= Url.Action("EditBuildDocument", "BuildDocument", new { bldDocId = item.BldDocId })%>'>
<img src="../../html/images/Edit.gif" alt="edit" border="0" /></a>
</td>
<td align="center">
<%--<%= Html.ActionLink("Delete", "DeleteBuildDocument", new { bldDocId = item.BldDocId }, new {@class ="delete-link" })%>--%>
<a>
<img src="../../html/images/inst-delete-ico.gif" alt="delete" border="0" /></a>
</td>
</tr>
<% } %>
</table>
</li>
<%} %>
</ul>
</div>
</div>
$.post("/BuildDocument/DeleteBuildDocument", {need to pass id here..});
にはid(BldDocId)が必要です。どうすれば入手できますか?
ご協力いただければ幸いです。
以前の回答に対する回答をご確認ください。ここで「ありがとう」と言う方法です。 – zerkms