Applying disabled class to only certain links
Applying disabled class to only certain links
xtremer360
Posts: 84Questions: 2Answers: 0
I'm trying to find out how I can only assign the class name of paginate_button_disabled when your on page 1 for the first and previous links but not sure how and obviously when your on the last page then the same goes for the last and next buttons.
This discussion has been closed.
Replies
Having said that - doesn't it do that already? "paginate_button_disabled" is applied to the first and previous buttons on the first page.
Allan
Allan
Allan
.paginate_button_disabled {
border: 1px solid #F3F3F3;
color: #CCCCCC;
margin-right: 2px;
padding: 2px 5px;
}
.paginate_button:hover {
border:1px solid #52bfea;
color: #fff;
background-color: #52bfea;
}
.paginate_active {
padding: 2px 5px 2px 5px;
margin-right: 2px;
border: 1px solid #52bfea;
font-weight: bold;
background-color: #52bfea;
color: #FFF;
}
.paginate_button {
padding: 2px 5px 2px 5px;
margin-right: 2px;
color: #52BFEA;
border: 1px solid #52BFEA;
}
http://jsfiddle.net/Rx8se/
Right but if you notice it has the disabled styles crossed off when it shouldn't because with the table having no data then all 4 of those buttons should be disabled.
After every time your table is drawn, you can get the count of rows drawn, and disable or enable the buttons if the number of rows is less than or greater-than-or-equal-to 1 row:
[code]
oTable = $('#your_table').dataTable( {
fnDrawCallback: function() {
iDisplayLength = oTable.fnSettings().aiDisplay.length;
if (iDisplayLength < 1) disable_buttons();
else enable_buttons();
}
});
[/code]
[code]$('#templatesPageList').dataTable( {
"sDom": 'rti<"pagination"p>',
"iDisplayLength": 1,
"sPaginationType": "full_numbers",
if ("iDisplayLength" < 1) disable_buttons();
else enable_buttons();
} );
[/code]
something like:
[code]
$('#templatesPageList').dataTable( {
"sDom": 'rti<"pagination"p>',
"iDisplayLength": 1,
"sPaginationType": "full_numbers",
"fnDrawCallback": function () {
iLength = oTable.fnSettings().aiDisplay.length;
if (iLength < 1) disable_buttons();
else enable_buttons();
iDisplayLength = oTable.fnSettings()._iDisplayLength;
iRecordsDisplay = parseInt(oTable.fnSettings()._iRecordsDisplay) ;
iCurrentPage = Math.floor(iRecordsDisplay / iDisplayLength);
iLastPage = iRecordsDisplay - iDisplayLength;
disable_current_button(iCurrentPage);
if (oTable.fnSettings()._iDisplayStart < 1) disable_first_button();
if (oTable.fnSettings()._iDisplayStart >= iLastPage ) disable_last_button();
}
} );
[/code]