diff --git a/index.html b/index.html index 70f82ab..a874e93 100644 --- a/index.html +++ b/index.html @@ -18,6 +18,12 @@
Titre | diff --git a/index.js b/index.js index e9f5145..10c9336 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,9 @@ var app = new Vue({ el: '#app', data: { books: [], - booksCount: 0 + booksCount: 0, + page: 1, + perpage: 20 }, methods: { sendQuery: function(url, error, success) { @@ -42,8 +44,19 @@ var app = new Vue({ booksSuccess: function(resp) { this.books = resp; }, + prevPage: function() { + if (this.page > 1) { + this.page--; + this.loadBooks(); + } + }, + nextPage: function() { + this.page++; + this.loadBooks(); + }, loadBooks: function() { - this.sendQuery('cgi-bin/bouquins/books', this.stdError, this.booksSuccess); + this.sendQuery('cgi-bin/bouquins/books?page=' + this.page + '&perpage=' + this.perpage, + this.stdError, this.booksSuccess); } }, mounted: function() {
---|