BookStack/resources/assets/js/pages/book-show.js
2015-11-22 13:12:15 +00:00

32 lines
914 B
JavaScript

module.exports = {
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.$els.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 = '';
}
}
};