I have a paginator on my website, and I need add a button that allows show all results without pagination.
For the pagination, I have this script:
jQuery(function()
{
var items = $("article.inmueble");
var numItems = items.length;
var perPage = 5;
items.slice(perPage).hide();
jQuery("#paginador").pagination({
items: numItems,
itemsOnPage: perPage,
cssStyle: 'light-theme',
onPageClick: function(pageNumber) {
var showFrom = perPage * (pageNumber - 1);
var showTo = showFrom + perPage;
items.hide()
.slice(showFrom, showTo).show();
}
});
});
This code is in js/initialize_paginator.js
.
In my index.php
I call this script:
<script type="text/javascript" src="js/initialize_paginator.js"></script>
And in this index.php
I have a button:
<button class="btn btn-default btn-sm">Ver todo</button>
How I can do to, when click this button, change the var perPage = 5;
to (for example) var perPage = 999999999;
to show all results?
perPage
is only available in the specific ready handler scope. You could make global it by removingvar
statement