Der Versuch, einen jquery-Dialog zu verwenden, bestätigt, Datensätze in einer jquery-Datentabelle zu löschen. Das Löschen funktioniert auf der ersten Seite laden, aber wenn ich Seiten oder Suche ändern funktioniert der Link zum Löschen nicht.Jquery-Dialog Bestätigung funktioniert nicht in Jquery Datatable
<script type="text/javascript">
$(document).ready(function() {
$('#dataTable').dataTable({
"aoColumnDefs": [
{ "bSortable": false, "bSearchable": false, "aTargets": [2] }
]
});
//modal popup
$("#dialog-confirm").dialog({
autoOpen: false,
resizable: false,
height: 200,
width: 400,
modal: true,
buttons: {
"Delete": function() {
$(this).dialog("close");
$("form")["delete"].submit();
},
Cancel: function() {
$(this).dialog("close");
}
}
});
$(".deleteLink").click(function (e) {
e.preventDefault();
$("#dialog-confirm").dialog("open");
});
// $.ajaxSetup({ cache: false });
});
Hier html.
<table cellpadding="0" cellspacing="0" border="0" class="display" id="dataTable">
<thead>
<tr>
<th>
@Html.LabelFor(p => Model.FirstOrDefault().LastName)
</th>
<th>
@Html.LabelFor(p => Model.FirstOrDefault().FirstName)
</th>
<th>
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.UserId }) |
@Html.ActionLink("Details", "Details", new { id = item.UserId }) |
@Html.ActionLink("Delete", "DeleteConfirmed", new { id = item.UserId }, new { @class = "deleteLink" })
@using (Html.BeginForm("DeleteConfirmed", "User", new { id = item.UserId})){}
</td>
</tr>
}
</tbody>
Hier Dialog bestätigen
<div id="dialog-confirm" title="Delete the item?" style="display:none" >
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This item will be deleted. Are you sure?</p>
gelöst. Antwort gefunden in [link] (http://datatables.net/faqs) Jquery Databases FAQ. Meine Ereignisse funktionieren nicht auf der zweiten Seite. –
mit mvc 3 C# rasierer ansicht? – Thulasiram