depicts/static/js/app.js

31 lines
563 B
JavaScript
Raw Normal View History

2019-09-25 13:41:27 +01:00
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;
})
}
},
});