BookStack/resources/assets/js/book-dashboard.js
2015-09-02 14:39:54 +01:00

31 lines
923 B
JavaScript

var bookDashboard = new Vue({
el: '#book-dashboard',
data: {
searching: false,
searchTerm: '',
searchResults: ''
},
methods: {
searchBook: function (e) {
e.preventDefault();
var term = this.searchTerm;
if (term.length == 0) return;
this.searching = true;
this.searchResults = '';
var searchUrl = this.$$.form.getAttribute('action');
searchUrl += '?term=' + encodeURIComponent(term);
this.$http.get(searchUrl, function (data) {
this.$set('searchResults', data);
});
},
checkSearchForm: function (e) {
if (this.searchTerm.length < 1) {
this.searching = false;
}
},
clearSearch: function(e) {
this.searching = false;
this.searchTerm = '';
}
}
});