Vue-multiselect: Using with vue-resource

Created on 4 Nov 2016  Â·  4Comments  Â·  Source: shentao/vue-multiselect

Hello Friend,

First, congratulations on the component. I'ts very interesting. Elegant!

I have a question: how to use it with external resources, type Restful APIs and "vue-resource"?

Thank you.

question

Most helpful comment

Well, there is no need for some dedicated integration for asynchronous libraries like vue-resource etc. Which means by itself vue-multiselect won’t make any requests as this is not it’s responsibility.

However, you can use multiselect with options lists that you just fetched from the API. Or use the search phrase you type into the multiselect as a query added to the ajax request.

Please look at the http://monterail.github.io/vue-multiselect/#ajax example.

First, you should probably disable the :local-search prop passing false. Add @search-change="asyncFind" to handle the changes in the search query. asyncFind should be a method used to fetch matching options from the backend. When you get the response from your server, simply update the options prop. The list inside multiselect will refresh automatically.
If you want to show a loading indicator while the request is made – just change the :loading prop to true for the time between the request and the response.

That’s all :)

All 4 comments

Well, there is no need for some dedicated integration for asynchronous libraries like vue-resource etc. Which means by itself vue-multiselect won’t make any requests as this is not it’s responsibility.

However, you can use multiselect with options lists that you just fetched from the API. Or use the search phrase you type into the multiselect as a query added to the ajax request.

Please look at the http://monterail.github.io/vue-multiselect/#ajax example.

First, you should probably disable the :local-search prop passing false. Add @search-change="asyncFind" to handle the changes in the search query. asyncFind should be a method used to fetch matching options from the backend. When you get the response from your server, simply update the options prop. The list inside multiselect will refresh automatically.
If you want to show a loading indicator while the request is made – just change the :loading prop to true for the time between the request and the response.

That’s all :)

Very good! Tks

Its working with vuejs 2.0, right?

Yes ofc! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

volkanciloglu picture volkanciloglu  Â·  3Comments

shsmad picture shsmad  Â·  3Comments

focussing picture focussing  Â·  3Comments

wujekbogdan picture wujekbogdan  Â·  4Comments

Uninen picture Uninen  Â·  4Comments