Page
This commit is contained in:
parent
0ac0010532
commit
155f4c2d24
@ -18,6 +18,12 @@
|
||||
<button class="btn btn-primary" type="button" @click="loadBooks">Livres</button>
|
||||
</div>
|
||||
<div class="table-responsive" v-if="books.length > 0">
|
||||
<nav aria-label="Pages">
|
||||
<ul class="pager">
|
||||
<li class="previous" v-bind:class="{ disabled: page <= 1 }"><a href="#" @click="prevPage"><span aria-hidden="true">←</span> Précédents</a></li>
|
||||
<li class="next"><a href="#" @click="nextPage">Suivants <span aria-hidden="true">→</span></a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Titre</th>
|
||||
|
17
index.js
17
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user