I have integrated the vue-typeahead component into my Laravel project using vue-typeahead.
However, I am facing an issue where when I select an entry from the result list by pressing the "enter" key, the form automatically submits. Is there a way to prevent this behavior in the onHit method?
Below is the code snippet of my component:
import VueTypeahead from 'vue-typeahead';
import Axios from 'axios';
Vue.prototype.$http = Axios;
var elem;
export default {
extends: VueTypeahead,
props: ['targetInput', 'keywordCategory', 'append'],
data () {
return {
src: '/api/autocomplete',
data: {
query: this.query,
category: this.keywordCategory,
append: this.append
},
limit: 10,
minChars: 3,
selectFirst: true,
queryParamName: 'search'
}
},
methods: {
onHit (item) {
elem = document.getElementById(this.targetInput);
if(this.append !== undefined && elem.value !== '') {
elem.value += this.append + item.name;
} else {
elem.value = item.name;
}
}
}
}