Closed nielslucas closed 4 years ago
@nielslucas
This happens because of memory leak in line 94:
this.$element.removeData('twbs-pagination');
When you call destroy method second time and initialize new pagination, variable "data" in line 318 takes recently destroyed pagination value:
var data = $this.data('twbs-pagination');
The solution of this problem is:
<div id="pag">
<div id="pagination-container"></div>
</div>
$pagination.twbsPagination('destroy');
remove pagination container
$pagination.remove();
,$('#pag').html('<div id="pagination-container" class="d-flex justify-content-center"></div>'); $pagination = $('#pagination-container'); $pagination.twbsPagination(paginationOptions);
For some reason, this does not happen to me. My code is:
<ul id="sm_pagination"></ul>
const $pagination = $('#sm_pagination');
function setupPagination(pagination)
{
const totalPagesCount = Math.max(Math.ceil(pagination.nbResults / ROWS_PER_PAGE), 1);
const visiblePagesCount = Math.min(totalPagesCount, 5);
$pagination.twbsPagination('destroy');
$pagination.twbsPagination({
startPage: pagination.currentPage,
totalPages: totalPagesCount,
visiblePages: visiblePagesCount,
initiateStartPageClick: false,
onPageClick(event, page) {
loadTable(page);
}
});
}
setupPagination()
is called on every page click, but it seems to be doing just fine.
Just use <ul>
instead <div>
as container.
Hi,
I have an problem with re-initialize. Cause it is not showing the pagination.
here is my code:
very simple test, create it, destroy it, create it again. If I dont destroy it and call it again, then the pagination works just fine. But i need to destroy it for search results and the page count will change.
information: