KazanExpress / vue-simple-suggest

Feature-rich autocomplete component for Vue.js
https://kazanexpress.github.io/vue-simple-suggest/
MIT License
461 stars 74 forks source link

List method always gets the previous model value #531

Open zhukovsergei opened 2 years ago

zhukovsergei commented 2 years ago

I'm submitting a ...

What is the current behavior?

The list :list="getSuggestionList" method is called before the model data have been set

Maybe I do something wrong but:

  <vue-simple-suggest
      v-model="chosen"
      display-attribute="name"
      value-attribute="url"
      :list="getSuggestionList"
      @select="handleSelectedTask"
      ref="taskSelectorComponent"
  >

methods:

  getSuggestionList() {
console.log(this.chosen);
      if(this.chosen.length < 2) {
          return [];
      }

      return axios.get(`/api/reports/search-list/${this.chosen}`)
          .then(response => {
              return response.data;
          });
  },

When I start to type console.log(this.chosen); in getSuggestionList method I'm getting previous value.

e.g. Real typed: 1234 on console: 123

Is it possible make ajax request with actual data? The event @request-start has an actual parameter value but how to set the ajax result into suggested list?

elionaimelo commented 2 years ago

debounce="200" solve it