josecebe / twbs-pagination

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

[solved] onPageClick self-run on page load #139

Closed gubi closed 7 years ago

gubi commented 7 years ago

The code in line 35~37 is bugged because run itself if onPageClick is defined. Here the piece of code:

if (this.options.onPageClick instanceof Function) {
    this.$element.first().on('page', this.options.onPageClick);
}

I fixed by removing it and then adding the following code in line 225:

if (_this.options.onPageClick instanceof Function) {
    _this.options.onPageClick(evt, _this.currentPage);
}

Best regards and thank you for this plugin :+1:

Richeir commented 7 years ago

Thank you!! This trouble me a lot.

pavelthq commented 7 years ago

You can use : initiateStartPageClick: false isn'it?

Richeir commented 7 years ago

Just noticed in the '$.fn.twbsPagination.defaults = {' Thank you! @AngeIII I think this property should be 'false' in default...maybe.

pavelthq commented 7 years ago

Actually many people uses onPageClick event when pagination initializes. For example to fetch data from ajax, or to show some animations. Due to backward compatibility this option cannot be changed to false by default

Richeir commented 7 years ago

Got That. Thanks for your contributions.