我在寻找的东西非常简单,但它却在逃避我,我无法在任何地方找到一个好例子。ASP.NET MVC 5 jQuery AJAX主/细节表
我有实体的MVC剃刀循环:
@foreach (var item in Model)
{
<tr>
<td>
<a href="#" id="stockIndexLink">
@Html.DisplayFor(modelItem => item.Name)
</a>
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
<tr id="componentRow">
<td id="componentCell">
</td>
</tr>
}
在jQuery中,我想详细PartialView加载到 'componentCell',有点像这样:
@section Scripts {
<script>
$(function() {
$("#componentRow").hide();
$("#stockIndexLink").on("click", function() {
$("#componentRow").slideToggle(300, function() {
$("#componentCell").load('@Url.Action("GetStockIndices", "AdminStockIndex", new { id = 1 })');
});
});
});
</script>
}
。 ..你可以看到,我已经将id值硬编码到Url.Action中,只是为了看它是。我如何从每一行中获取该ID,进入“点击”事件,而没有丑陋的黑客?此外,我知道我有一些工作要做,隐藏和切换的东西......但我可以处理。该id是什么让我绊倒。
谢谢!
为什么downvote?无礼。 –