Add item page Javascript.

This commit is contained in:
Edward Betts 2019-09-25 13:41:27 +01:00
parent 0a575b7b69
commit 0cef952f17

30
static/js/app.js Normal file
View file

@ -0,0 +1,30 @@
var app = new Vue({
el: '#app',
data: {
searchTerms: '',
hits: [],
new_depicts: [],
},
methods: {
add_depicts(hit) {
this.new_depicts.push(hit);
this.hits = [];
this.searchTerms = '';
},
search(event) {
var terms = this.searchTerms;
if (terms.length < 3) {
this.hits = [];
return;
}
var vm = this;
fetch(lookup_url + '?terms=' + encodeURI(terms))
.then((res) => res.json())
.then((data) => {
vm.hits = data.hits;
})
}
},
});