From fb94441e3b2c829119e1ee0c1c36079ff9157012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Cebell=C3=A1n=20S=C3=A1nchez?= Date: Sun, 29 Jul 2018 19:23:00 +0200 Subject: [PATCH] #148 Create 'beforePageClick' method --- jquery.twbsPagination.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jquery.twbsPagination.js b/jquery.twbsPagination.js index ab625b8..ff76812 100644 --- a/jquery.twbsPagination.js +++ b/jquery.twbsPagination.js @@ -32,6 +32,10 @@ throw new Error('Visible pages option is not correct!'); } + if (this.options.beforePageClick instanceof Function) { + this.$element.first().on('beforePage', this.options.beforePageClick); + } + if (this.options.onPageClick instanceof Function) { this.$element.first().on('page', this.options.onPageClick); } @@ -99,6 +103,8 @@ } this.currentPage = page; + this.$element.trigger('beforePage', page); + var pages = this.getPages(page); this.render(pages); this.setupEvents(); @@ -333,6 +339,7 @@ next: 'Next', last: 'Last', loop: false, + beforePageClick: null, onPageClick: null, paginationClass: 'pagination', nextClass: 'page-item next',