I recently discussed with jqPagination , which is a jQuery pagination plugin. This is a really neat plugin, and I like how you can enter the page number. However, I have some difficulties because there is little documentation on it. Although this is probably a simple question, I was just curious if there is a way to specify how many posts will be displayed on the page. I am currently using pagination for a single entry per page, and this is controlled by jQuery selectors. However, I would like to indicate the number of numbers.
It might be easier to show some code that I have. I actually used the previous question stack overflow as the basis:
<div id="container"> <div id="div1">Any elements</div> <div id="div2">Any elements</div> <div id="div3">Any elements</div> ... and so on </div>
And for jQuery:
//Hide $("#container").children().not('#firstDiv').hide(); $('.pagination').jqPagination( { max_page : $('#container').children().length, paged : function(page) { //hide the other divs $('#container').children().hide(); //show the divs on the specified page $($('#container').children()[page - 1]).show();
Thus, in the above code, only one div will be displayed at a time, I would like to indicate how many elements / sections it can show.
Oh, and as a follow-up question, you can specify a specific div to display on a specific page, for example. if the footer only appears on the last page?
Update: completed
With the help of the creator, I was able to figure this out. I post my decision below in case someone can help someone else in the future. I have a user who selects the number of records per page in an XML file (not including the XML selector). If the page has fewer entries than the total, this displays pagination. I am sure there is a more efficient way, but I am satisfied with what I have. Here is the code below:
$(".pagination").hide(); var recordsPerPage = 5 var totalNumRecords = 20; if (recordsPerPage < totalNumRecords) { pagination(recordsPerPage, totalNumRecords); }
Thanks Ben!