Loading static/components/pieces/Pagination.js +2 −4 Original line number Diff line number Diff line Loading @@ -6,13 +6,11 @@ export default { view(vnode) { const elements = vnode.attrs.elements.toArray() const totalPages = Math.ceil(elements.length / ELEMENTS_PER_PAGE) const currentPageIndex = 0 const startIndex = currentPageIndex * ELEMENTS_PER_PAGE const startIndex = (this.currentPageIndex || 0) * ELEMENTS_PER_PAGE return [ elements.slice(startIndex, startIndex + ELEMENTS_PER_PAGE), // TODO Actually change the contents on page change m(PaginationControls, { currentPage: currentPageIndex + 1, totalPages, onPageChange: console.log }) m(PaginationControls, { currentPage: (this.currentPageIndex || 0) + 1, totalPages, onPageChange: i => this.currentPageIndex = i-1 }) ] } } Loading
static/components/pieces/Pagination.js +2 −4 Original line number Diff line number Diff line Loading @@ -6,13 +6,11 @@ export default { view(vnode) { const elements = vnode.attrs.elements.toArray() const totalPages = Math.ceil(elements.length / ELEMENTS_PER_PAGE) const currentPageIndex = 0 const startIndex = currentPageIndex * ELEMENTS_PER_PAGE const startIndex = (this.currentPageIndex || 0) * ELEMENTS_PER_PAGE return [ elements.slice(startIndex, startIndex + ELEMENTS_PER_PAGE), // TODO Actually change the contents on page change m(PaginationControls, { currentPage: currentPageIndex + 1, totalPages, onPageChange: console.log }) m(PaginationControls, { currentPage: (this.currentPageIndex || 0) + 1, totalPages, onPageChange: i => this.currentPageIndex = i-1 }) ] } }