josecebe / twbs-pagination

jQuery pagination plugin (bootstrap powered)
http://josecebe.github.io/twbs-pagination/
Other
1.1k stars 401 forks source link

A tiny inconvenience when using twbsPagination. #141

Closed JimmyBenKlieve closed 7 years ago

JimmyBenKlieve commented 7 years ago
<ul id="my-pagination" class="pagination pagination-sm">
</ul>

Every time I

$('#my-pagination').twbsPagination('destroy');
$('#my-pagination').twbsPagination({
  totoalPages: iExpectPages,
  startPage: Math.min(iExpectPages, iCurrentPage),
});

then I have to re-setup my event listener using jQuery on method, though I've done this at the very first time.

$('#my-pagination').on('page', (e, p) => { /*my code goes here*/ });

So I read the code, found at line 89 caused this tiny inconvenience.

In my opnion, I don't think you need to do this.$element.off('page') in destroy method, because might I have more than one event listener listening page event. Plugin version: 1.4.1

pavelthq commented 7 years ago

If we will not use off this will be a possible memory leak.