【发布时间】:2013-09-01 09:09:01
【问题描述】:
我已经完成了一行remove(),然后我尝试fnDestroy() 并重新初始化DataTable。 记录计数和分页不受影响(*DataTable 未刷新)*。
我也尝试过使用fnDraw(),但仍然没有用。
我查看了页面源代码,删除的行 html 仍然存在。
我正在使用 Ajax 删除该行。感谢您的帮助
这是我的删除脚本:
$(document).ready(function()
{
$('table#sample_1 td a.delete').click(function()
{
if (confirm("Are you sure you want to delete this row?"))
{
var id = $(this).parent().parent().attr('id');
var data = 'id=' + id ;
var parent = $(this).parent().parent();
$.ajax(
{
type: "POST",
url: "process.php",
dataType: "json",
data: data,
cache: false,
success: function()
{
var dtable = $('#sample_1').dataTable();
dtable.fnDestroy();
parent.fadeOut('slow', function() {$(this).remove();});
//Reinitialize the datatable
$('#sample_1').dataTable({
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap",
"oLanguage": {
"sLengthMenu": "_MENU_ records per page",
"oPaginate": {
"sPrevious": "Prev",
"sNext": "Next"
}
},
"aoColumnDefs": [{
'bSortable': false,
'aTargets': [0]
}]
});
}
});
}
});
});
</script>
【问题讨论】:
-
试试
$("element").hide().fadeIn('fast');
标签: jquery html ajax datatable