0
您好我是MVC和jQuery的新手。 任何人都可以请引导我下面请。 当我点击删除链接时,删除操作从未命中。JQuery确认没有命中控制器中的操作方法
笔者认为:
<table id="lookupValuesDetailsTable" class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Value</th>
<th>Message</th>
<th>EffectiveDate</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.LookupValues)
{
<tr>
<td>@Html.DisplayFor(m => item.Value)</td>
<td>@Html.DisplayFor(m => item.Message)</td>
<td>@Html.DisplayFor(m => item.EffectiveDate)</td>
@* <td>@Html.DisplayFor(m => item.EffectiveDateDateForSorting)</td>*@
<td>
@Html.ActionLink("Delete", "Delete", "LookupValues", new { area = "Admin", id = item.LookupValueKey }, new { @class = "deleteLink" })
</td>
</tr>
}
</tbody>
</table>
<div id="dialog-confirm" title="CONFIRMATION" class="modal-header">
<div class="modal-body">
<p>This item will be deleted. Are you sure?</p>
</div>
</div>
@section Scripts {
<script type="text/javascript">
$("#dialog-confirm").dialog({
autoOpen: false,
modal: true,
resizable: false,
height: 180,
});
$(".deleteLink").click(function (e) {
e.preventDefault();
var targetUrl = $(this).attr("href");
$("#dialog-confirm").dialog({
buttons: {
"Confirm": function() {
window.location.href = targetUrl;
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
$("#dialog-confirm").dialog("open");
});
</script>
我控制器(LookupValuesController):
[HttpPost]
public ActionResult Delete(Guid id)
{
var lookupValueDetails = adminService.GetLookupValues(id);
var model = AddLookupValueMappings.ToModel(id, lookupValueDetails);
return View();
}
谁能告诉我,我在做什么错。
您好,我试图删除的是,现在我连能看到模式弹出。尽管没有达到行动方法。 –
为什么你为同一个id写了2次对话函数?删除第一个,并检查它 –