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次對話函數?刪除第一個,並檢查它 –