bjorn2404 / jQuery-Store-Locator-Plugin

A store locator plugin using Google Maps API version 3
MIT License
495 stars 235 forks source link

is it possibile doesn't show all number in the pagination? #82

Closed manucnx closed 8 years ago

manucnx commented 8 years ago

ex, i want show 1 2 . . . . 10 next>>

bjorn2404 commented 8 years ago

That's not currently built in.

manucnx commented 8 years ago

I try this code.

_paginationOutput: function(currentPage, totalPages) { this.writeDebug('_paginationOutput',arguments); currentPage = parseFloat(currentPage); var output = ''; var nextPage = currentPage + 1; var prevPage = currentPage - 1; // Previous page if( currentPage > 0 ) { output += '

  • ' + this.settings.prevPage + '
  • '; } // Add the numbers for (var p = 0; p < Math.ceil(totalPages); p++) { var n = p + 1; if (p >= 2 && p < totalPages - 1) { continue; } else { output += '
  • ' + n + '
  • '; } } // Next page if( nextPage < totalPages ) { output += '
  • ' + this.settings.nextPage + '
  • '; } return output; },

    stitchy commented 8 years ago

    @manucnx Your code helped me a great deal. I set it so that the pagination shows the first 5 pages and then the final page.

    However, I have an issue now where if I use the "Next" button and I keep pressing that until I'm past page 5, the next set of pages (6-10, for example) doesn't show up. It still shows << Prev 1 2 3 4 5 400 Next>>

    Do you know how to address this?

    This is my code for that section (based on what you did):

    _paginationOutput: function(currentPage, totalPages) {
                this.writeDebug('_paginationOutput',arguments);
                currentPage = parseFloat(currentPage);
                var output = '';
                var nextPage = currentPage + 1;
                var prevPage = currentPage - 1;
                // Previous page
                if( currentPage > 0 ) {
                    output += '<li class="bh-sl-next-prev" data-page="' + prevPage + '">' + this.settings.prevPage + '</li>'; 
                }
                // Add the numbers
                for (var p = 0; p < Math.ceil(totalPages); p++) {
                    var n = p + 1;
                    if (p >= 5 && p < totalPages - 1) {
                        continue;
                    }
                    else {
                        //output += '<li class="bh-sl-next-prev" data-page="' + nextPage + '">' + n + '</li>'; 
                        if (p === currentPage) {
                            output += '<li class="bh-sl-current" data-page="' + p + '">' + n + '</li>';
                        }
                        else {
                            output += '<li data-page="' + p + '">' + n + '</li>';
                        }
    
                    }
                }
                // Next page
                if( nextPage < totalPages ) {
                    output += '<li class="bh-sl-next-prev" data-page="' + nextPage + '">' + this.settings.nextPage + '</li>';
                    //<li class="bh-sl-next-prev" data-page="' + nextPage + '">' + this.settings.nextPage + '</li>
                }
                    return output;