Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List method always gets the previous model value #531

Open
zhukovsergei opened this issue Mar 15, 2022 · 1 comment
Open

List method always gets the previous model value #531

zhukovsergei opened this issue Mar 15, 2022 · 1 comment

Comments

@zhukovsergei
Copy link

zhukovsergei commented Mar 15, 2022

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?

@elionaimelo
Copy link

debounce="200" solve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants