Not removing pagination div
Not removing pagination div

I'm trying to figure out how to have it remove the pagination div when there is no data returned into the table and the code I have is not working.
[code]
var oTable = $('#templatesPageList').dataTable( {
"sDom": 'rti<"pagination"p>',
"iDisplayLength": 10,
"sPaginationType": "full_numbers",
"fnDrawCallback":function(){
if(oTable.find("tbody tr").length == 0){
$('div.pagination').remove();
}
}
[/code]
[code]
var oTable = $('#templatesPageList').dataTable( {
"sDom": 'rti<"pagination"p>',
"iDisplayLength": 10,
"sPaginationType": "full_numbers",
"fnDrawCallback":function(){
if(oTable.find("tbody tr").length == 0){
$('div.pagination').remove();
}
}
[/code]
This discussion has been closed.
Replies
This also assumes that there's a div called 'pagination'.
[code]
var oTable = $('#templatesPageList').dataTable( {
"sDom": 'rti<"pagination"p>',
"iDisplayLength": 10,
"sPaginationType": "full_numbers",
"fnDrawCallback":function(){
if($('#templatesPageList tbody tr').length <= 10 || ($('#templatesPageList tbody td.dataTables_empty').length > 0)) {
$('div.pagination').remove();
}
if($('#templatesPageList tbody td.dataTables_empty').length == 0) {
$('div.pagination').remove();
}
});
[/code]
[code]
var oTable = $('#templatesPageList').dataTable( {
"sDom": 'rti<"pagination"p>',
"iDisplayLength": 10,
"sPaginationType": "full_numbers",
"fnDrawCallback":function(){
if(oTable.fnSettings().fnRecordsTotal() <= 10) {
$('div.pagination').remove();
} else {
$('div.pagination').append();
}
if(oTable.fnSettings().fnRecordsTotal() == 0) {
$('.bt_red').remove();
$('.bt_blue').remove();
}
}
});
[/code]