diff --git a/ignite-template.js b/ignite-template.js index 97ee2fb..b4b19e1 100644 --- a/ignite-template.js +++ b/ignite-template.js @@ -3735,17 +3735,21 @@ class pager extends IgniteTemplate { //Construct the pages if (this.pageCount > 0) { + var last = this.element; + //Construct the first page var firstPage = this.renderCallback(0, this.currentPage == 0, false); - firstPage.construct(parent, this.element); + firstPage.construct(parent, last); this.pages.push(firstPage); + last = firstPage.element; //If the number of pages is less than or equal to the page range, just render all the numbers inbetween first/last. if (this.pageCount <= this.pageRange) { for (var i = 1; i < this.pageCount - 1; i++) { var page = this.renderCallback(i, i == this.currentPage, false); - page.construct(parent, this.element); + page.construct(parent, last); this.pages.push(page); + last = page.element; } } else { var leftSiblingIndex = Math.max(this.currentPage - this.pageRange, 1); @@ -3767,24 +3771,27 @@ class pager extends IgniteTemplate { if (shouldShowLeftDots) { var page = this.renderCallback(leftSiblingIndex - 1, false, true); if (page) { - page.construct(parent, this.element); + page.construct(parent, last); this.pages.push(page); + last = page.element; } } for (var i = leftSiblingIndex; i <= rightSiblingIndex; i++) { var page = this.renderCallback(i, i == this.currentPage, false); if (page) { - page.construct(parent, this.element); + page.construct(parent, last); this.pages.push(page); + last = page.element; } } if (shouldShowRightDots) { var page = this.renderCallback(rightSiblingIndex + 1, false, true); if (page) { - page.construct(parent, this.element); + page.construct(parent, last); this.pages.push(page); + last = page.element; } } } @@ -3792,8 +3799,9 @@ class pager extends IgniteTemplate { //Construct the last page if we have more than 1 page. if (this.pageCount > 1) { var lastPage = this.renderCallback(this.pageCount - 1, this.currentPage == this.pageCount - 1, false); - lastPage.construct(parent, this.element); + lastPage.construct(parent, last); this.pages.push(lastPage); + last = lastPage.element; } } }