Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links should update when number of pages changes #13

Merged
merged 3 commits into from
Sep 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dist/vue-paginate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-paginate v2.1.0
* vue-paginate v2.1.1
* (c) 2016 Taha Shashtari
* Released under the MIT License.
*/
Expand Down Expand Up @@ -205,7 +205,7 @@
}, {
key: 'initialOfLastNav',
value: function initialOfLastNav() {
var numberOfNavs = ~ ~(this.list.numberOfPages / this.limit);
var numberOfNavs = ~~(this.list.numberOfPages / this.limit);
var rest = this.list.numberOfPages - this.limit * numberOfNavs;

rest = rest <= 1 ? rest + this.limit : rest;
Expand Down Expand Up @@ -291,6 +291,7 @@

_this.list.currentPage = typeof page == 'number' ? page - 1 : page;

_this.setNumberOfPages(_this.originalList.length);
_this.setLimitedPages(limit);
};

Expand Down
4 changes: 2 additions & 2 deletions dist/vue-paginate.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/vue-paginate.min.js.gz
Binary file not shown.
1 change: 1 addition & 0 deletions src/paginate.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default {

this.list.currentPage = typeof page == 'number' ? page - 1 : page;

this.setNumberOfPages(this.originalList.length);
this.setLimitedPages(limit);
};

Expand Down
16 changes: 16 additions & 0 deletions test/functional/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ describe('Vue-Paginate', () => {

vm.$data.limitedLangsLinks.should.eql([1, 2, 3, 4, 5, 6, 7]);
});

it('should update when the list is updated', (done) => {
vm = new Vue({
template: '<div v-paginate:1="langs" limit="6">Hello</div>',
data: {
langs: ['PHP']
}
}).$mount();

vm.$data.fullLangs = ['PHP', 'JavaScript', 'HTML', 'CSS', 'Ruby', 'Python', 'Erlang'];

Vue.nextTick(() => {
vm.$data.limitedLangsLinks.should.eql([1, 2, 3, 4, 5, 6, 7]);
done();
});
});
});

describe('Dynamic perPage', () => {
Expand Down