var pager = new DataPage(total_entries, entries_per_page, current_page, pages_per_pageset);
pager.first_page();
pager.last_page();
pager.first();
pager.last();
pager.pageset() // 1,2,3,4,5...
// default value
// total_entries || 0
// entries_per_page || 10
// current_page || 1
// pages_per_pageset || 10
$ npm install datapage
Then:
var DataPage = require('datapage');
bower install datapage
Then:
<script src="datapage.js"></script>
new DataPage();
new DataPage(total_entries, entries_per_page, current_page, pages_per_pageset);
// default value
// total_entries || 0
// entries_per_page || 10
// current_page || 1
// pages_per_pageset || 10
sets or gets the total number of entries per page (which defaults 10)
// set
pager.entries_per_page(15);
// get
pager.entries_per_page();
// set
pager.current_page(2);
// get
pager.current_page();
// set
pager.total_entries(300);
// get
pager.pager.total_entries();
var total_entries = 300,
entries_per_page = 10,
current_page = 2,
pages_per_pageset = 5;
var pager = new DataPage(total_entries, entries_per_page, current_page, pages_per_pageset);
pager.entries_on_this_page(); // returns 10
var total_entries = 317,
entries_per_page = 10,
current_page = 32,
pages_per_pageset = 5;
var pager = new DataPage(total_entries, entries_per_page, current_page, pages_per_pageset);
pager.entries_on_this_page(); // returns 7
always returns 1
var pager = new DataPage(500, 30, 1);
pager.last_page(); returns 17
This software has been ported from Data::Page
© 2014 trapple
The "Artistic License"