diff options
author | Asbjørn Sloth Tønnesen <asbjorn@asbjorn.biz> | 2012-08-09 17:30:58 +0000 |
---|---|---|
committer | Asbjørn Sloth Tønnesen <asbjorn@asbjorn.biz> | 2012-08-09 17:30:58 +0000 |
commit | b1a5a0dd5dc0a7910c305b90c7084766f5a0d729 (patch) | |
tree | 3f066e198c382df75dbfe355e642dea67572cf6c /web/js/labitrack.d/43-browse.js | |
parent | 7c3af4ea9b75361e9d726d72ba587318e4e92c0f (diff) | |
download | labitrack-b1a5a0dd5dc0a7910c305b90c7084766f5a0d729.tar.gz labitrack-b1a5a0dd5dc0a7910c305b90c7084766f5a0d729.tar.xz labitrack-b1a5a0dd5dc0a7910c305b90c7084766f5a0d729.zip |
Pagination
Signed-off-by: Asbjørn Sloth Tønnesen <asbjorn@asbjorn.biz>
Diffstat (limited to 'web/js/labitrack.d/43-browse.js')
-rw-r--r-- | web/js/labitrack.d/43-browse.js | 43 |
1 files changed, 11 insertions, 32 deletions
diff --git a/web/js/labitrack.d/43-browse.js b/web/js/labitrack.d/43-browse.js index 7605e78..14399ac 100644 --- a/web/js/labitrack.d/43-browse.js +++ b/web/js/labitrack.d/43-browse.js @@ -1,4 +1,5 @@ (function(){ + function hdl_add(){ console.log('add'); } @@ -41,39 +42,14 @@ messages.bind("remove", hdl_remove, this); }, render: function(page){ + if (page) this.page = page; + page = this.page; var stats = this.collection.stats; var pages = []; - var dots = { id: 'dots', label: '…' }; - pages.push({ - id: 'first', - link: '/browse', - label: '|←', - classes: 'prev' - }); - pages.push({ - id: 'prev', - link: '/browse', - label: '←' - }); - pages.push(dots); - pgno = 1; - pages.push({ - id: pgno, - link: '/browse/'+pgno, - label: pgno - }); - pages.push(dots); - pages.push({ - id: 'next', - link: '/browse', - label: '→' - }); - pages.push({ - id: 'last', - link: '/browse', - label: '→|', - classes: 'next' - }); + if (stats !== undefined) { + var pgcnt = Math.ceil(stats.count / 10); + pages = λ.pagination(page, pgcnt); + } var data = { rows: this.collection.toJSON(), pages: pages @@ -92,13 +68,16 @@ }, render: function (page) { page || (page = 1); + page = parseInt(page, 10); + console.log('page', page); λ.setcontent('browse', {page: page}); this.browse.el = $(this.el).find('#objecttable_ph')[0]; + console.log(this.browse.render); this.browse.render(page); this.browse.collection.fetchpage(page); } }); view.route('browse'); - view.route('browse/:page'); + view.route('browse/page/:page'); }()); |