Search code examples
javascriptjquerypaginationlistjs

How can I set the page number in List.js?


I'm using the latest version of List.js (v1.5.0). I created a paginated list and I want that it starts showing a page that I chose (not the first). For example: I chose 3, I want that list starts showing page number 3. How can I set this page on JQuery? Thanks.


Solution

  • I found the way myself! List.js plug-in have show(i, page) method. Ref: http://listjs.com/api/#show. It has 2 parameters: "i" , that is the number of item of the list you want to show first, and "page", that is the number of items per page. So it shows the "page" number of items after the "i" item. So to select your page, you have to calculate the number of item you want to show! Example: I have a list of 18 items. Page is set to 6, so i have 3 pages. To set page 3 at first, I had to calculate what item is shown at first at that page (the item number 13), then i do show(13,6) and it's done!