Added vue book search.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<input type="text" v-model="searchTerm" @keydown.enter="search"/>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -52,13 +53,20 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
search: function () {
|
||||
this.updateHistory();
|
||||
axios.get('/api/books', {
|
||||
params: {title: this.searchTerm},
|
||||
headers: {'accept': 'application/json'}
|
||||
}).then(response => {
|
||||
this.books = response.data;
|
||||
});
|
||||
}).finally(() => window.EventBus.$emit('updateBookListingHeader', {searchTerm: this.searchTerm}));
|
||||
},
|
||||
updateHistory: function () {
|
||||
if (history.pushState) {
|
||||
let url = window.location.protocol + "//" + window.location.host + window.location.pathname + '?search=' + this.searchTerm;
|
||||
window.history.pushState({path: url}, '', url);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
Reference in New Issue
Block a user