diff --git a/jquery.simplePagination.js b/jquery.simplePagination.js index 4fa860e..4284cb0 100644 --- a/jquery.simplePagination.js +++ b/jquery.simplePagination.js @@ -105,12 +105,18 @@ return this; }, - drawPage: function (page) { + drawPage: function(page) { + methods.setPage.call(this, page, true); + }, + + setPage: function (page, forceDraw) { + forceDraw = typeof forceDraw !== 'undefined' ? forceDraw : false; var o = this.data('pagination'); o.currentPage = page - 1; - this.data('pagination', o); - methods._draw.call(this); - return this; + if (o.selectOnClick || forceDraw) { + methods._draw.call(this); + } + return o.onPageClick(pageIndex + 1, event); }, redraw: function(){ @@ -312,9 +318,7 @@ _selectPage: function(pageIndex, event) { var o = this.data('pagination'); o.currentPage = pageIndex; - if (o.selectOnClick) { - methods._draw.call(this); - } + methods._draw.call(this); return o.onPageClick(pageIndex + 1, event); }