开发者

Changing Datatables CSS functionality

开发者 https://www.devze.com 2023-03-18 20:31 出处:网络
I\'m having trouble figuring out how to work with the Datatables plugin for jQuery in the fact that I need for example if there are 3 numbered page links which would have the First, Previous, Next, La

I'm having trouble figuring out how to work with the Datatables plugin for jQuery in the fact that I need for example if there are 3 numbered page links which would have the First, Previous, Next, Last links as well. If you were on page 1 then the First, Previous buttons should only have the pagination_button_disabled css applied to it but instead it ALSO has the paginate button and then the f开发者_如何学Cirst or previous css style as well. I just want the first and last to have a css style of paginate_button_disabled if you are on page 1 and obviously revered if you were on page 3 then Last and Next should be disabled.


Mmm maybe something like:

var currentPage = parseInt($(...).text(), 10);
var totalPages = parseInt($(...).text(), 10);
$(".page").removeClass("pagination_button_disabled"); //Enable all initially
if(currentPage == 1){
  $("#first, #previous").addClass("pagination_button_disabled");
}
if(currentPage == totalPages){
  $("#last, #next").addClass("pagination_button_disabled");
}

Hope this helps. Cheers


I think that even if they have the class 'paginate_button_disabled' no CSS for that class is defined (in fact all the CSS is inherited from the class 'paging_full_numbers'). I think you should define a css rule

.paging_full_numbers  .paginate_button_disabled{
    //put your rule for disabled content here
    color: gray;
}

after you load datatables CSS

EDIT - i edited your fiddle (only thing i modified is i loaded the source for datatables from the datatables.net site because the link of your script was broken).

I added this line of css

.dataTables_paginate .paginate_button_disabled{
     display:none;   
}

and the disabled button are hidden. Look here: http://jsfiddle.net/F7GLm/2/

0

精彩评论

暂无评论...
验证码 换一张
取 消