我对 DataTables 有奇怪的问题。我正在使用这些东西来删除行并且一切正常(行已从数据库中删除,警报正确显示),并且当我单击上一页并返回最初显示行的页面时,它会从显示中删除行(按页面我的意思是 DataTable 页码或我增加每页的行数) - 它再次显示......(因为它实际上没有被删除)
只有在硬刷新后它才会被删除。为什么会发生这种情况以及如何在不实际刷新浏览器的情况下真正删除它?
这是我用来删除行的代码:
function DeletePublisher(element, publisherid) {
jConfirm('Are you sure you want to delete this publisher?', 'Delete publisher', function (r) {
if (r) $.post('includes/publishers/delete-publisher.php?publisherid=' + publisherid,
function (data) {
if ($.trim(data) == 'error') {
$.jGrowl('This publisher was already deleted', {
header: '<strong style="text-align:center;">ERROR</strong>'
});
$(element)
.parents('tr')
.remove();
} else {
$(element)
.parents('tr')
.remove();
oTable.fnDeleteRow(element);
$('tr')
.removeClass();
// Now add class names again
$('tr:odd')
.addClass('odd');
$('tr:even')
.addClass('even');
$.jGrowl('Publisher deleted');
}
});
});
这是 TR 元素:
<td class="action-th">
<ul class="button-table-head">
<li><div class="button-head edit-icon"><a href="/includes/publishers/edit-publisher.php?editpublisher=<?php echo $publisher_id; ?>" data-fancybox-type="iframe" class="iframe sweet-tooltip" data-text-tooltip="Edit" data-style-tooltip="tooltip-mini-slick"><span>Edit</span></a></div></li>
<li><div class="button-head delete-icon"><a href="#" class="sweet-tooltip" data-text-tooltip="Delete" data-style-tooltip="tooltip-mini-slick" onclick="DeletePublisher(this,'<?php echo $publisher_id; ?>')"><span>Delete</span></a></div></li>
</ul>
</td>
所以不确定元素是否首先传递了正确的行 ID?