Twitter Bootstrap 2 Example - pagination fix

Twitter Bootstrap 2 Example - pagination fix

FlashJuniorFlashJunior Posts: 9Questions: 0Answers: 0
edited March 2012 in General
Hi. I made a small fix for http://datatables.net/blog/Twitter_Bootstrap_2.

Problem 1:
if you have turnt on "LengthMenu" and you select "All", "Previous" Button is disabled and "Next" Button is active.

test:
$.extend( $.fn.dataTable.defaults, {
"iDisplayLength": -1,
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"sPaginationType": "bootstrap"
} );

Problem 2:
if you filter the table and there is no matching record, "Previous" and "Next" Button are disabled.



i made a small fix for that. with this it doesn't show "Previous" and "Next" Button.
[code]
...
"fnInit": function(oSettings, nPaging, fnDraw){
var oLang = oSettings.oLanguage.oPaginate;
var fnClickHandler = function (e){
e.preventDefault();
if (oSettings.oApi._fnPageChange(oSettings, e.data.action)) {fnDraw(oSettings);}
};

$(nPaging).addClass('pagination').append("");
$('«').appendTo($("ul", nPaging)).find("a").bind('click.DT', {action: "previous"}, fnClickHandler);
$('»').appendTo($("ul", nPaging)).find("a").bind('click.DT', {action: "next"}, fnClickHandler);
}
...

$.extend( $.fn.dataTableExt.oPagination, {
...
"fnUpdate": function ( oSettings, fnDraw ) {
...
if(oPaging.iStart == 0 && oPaging.iEnd == oPaging.iTotal || oPaging.iEnd == 0){
$('.prev, .next, li', an).hide();
}else{
$('.prev, .next, li', an).show();
}
}
...[/code]
This discussion has been closed.