faulknercs / Knockstrap

Knockout bindings to twitter bootstrap 3
faulknercs.github.io/Knockstrap/
MIT License
142 stars 37 forks source link

When totalCount is 0 (zero), causes UI problem #57

Closed shinsou closed 7 years ago

shinsou commented 7 years ago

Hi,

Couldn't find any similar posts. (Apologies if one did exist tho')

I noticed that if [totalCount] is 0, your logic here breaks:

self.isForwardDisabled = ko.computed(function () {
    return self.currentPage() === self.pagesCount(); 
    // <-- problem, if pagesCount() == 0; where it is, if [totalCount] == 0
    //return self.currentPage() >= self.pagesCount(); <-- solved, or should I put logic to check if [totalCount] is zero, then change [currentPage] to zero?
});

and possible here:

self.isBackDisabled = ko.computed(function () {
    return self.currentPage() === 1; 
});

It allows to use [Next] and [Last] -buttons, causing the page numbering to become negative based. You can test this on your example (http://faulknercs.github.io/Knockstrap/#pagination) - just change [Total items] to 0 (zero) and press [Last] -button.

faulknercs commented 7 years ago

Duplicate of #46