vue-simple-suggest icon indicating copy to clipboard operation
vue-simple-suggest copied to clipboard

List method always gets the previous model value

Open zhukovsergei opened this issue 2 years ago • 1 comments

I'm submitting a ...

  • [x ] bug report
  • [x ] support request

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?

zhukovsergei avatar Mar 15 '22 03:03 zhukovsergei

debounce="200" solve it

elionaimelo avatar Jun 15 '22 14:06 elionaimelo