drafted ajax search call

This commit is contained in:
2019-06-01 16:15:08 +02:00
parent d21bd5ef4e
commit 7f65fd79a4
9 changed files with 278 additions and 17 deletions

View File

@ -33,7 +33,7 @@ export default {
}
},
beforeMount() {
console.log('LoginBlock beforeMount', this._props.block);
// console.log('LoginBlock beforeMount', this._props.block);
if(this._props.block){
// console.log('LoginBlock beforeMount if this._props.block ok');
this.template = Vue.compile(this._props.block)

View File

@ -2,20 +2,54 @@
import Vue from 'vue'
import { mapState, mapActions } from 'vuex'
export default {
props: ['form'],
data() {
return {
template: null,
typed: ""
template: null
// keys: "",
// autocomplete: ""
}
},
methods: {
keyup() {
console.log("search typed", this.typed);
computed: {
// ...mapState(['Search'])
// ...mapState({
// // keys: state => state.Search.keys,
// autocomplete: state => state.Search.autocomplete
// }),
keys: {
get(){
return this.$store.state.Search.keys
},
set(value){
this.$store.commit('Search/setKeys', value)
}
},
autocomplete: {
get(){
return this.$store.state.Search.autocomplete
},
set(value){
this.$store.commit('Search/setAutocomplete', value)
}
}
},
methods: {
...mapActions({
getResults: 'Search/getResults'
}),
submit() {
console.log("search clicked");
console.log("search clicked", this.keys, this.autocomplete);
this.getResults();
},
onAutoCompleteSelect(event, ui){
event.preventDefault();
// console.log('autoCompleteSelect', event, ui);
this.keys = ui.item.label
this.autocomplete = ui.item.value
}
},
beforeMount() {
@ -29,9 +63,16 @@ export default {
this.template.staticRenderFns.map(fn => (this.$options.staticRenderFns.push(fn)));
}
},
watch: {
keys(){
console.log('keys changed', this.keys);
}
},
mounted(){
// console.log('SearchForm mounted');
Drupal.attachBehaviors(this.$el);
// Catch the jquery ui events for autocmplete widget
jQuery(this.$el.querySelector('#edit-search')).on('autocompleteselect', this.onAutoCompleteSelect);
},
render(h) {
// console.log('searchForm render');