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.
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! :)
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-searchprop passingfalse. Add@search-change="asyncFind"to handle the changes in the search query.asyncFindshould be a method used to fetch matching options from the backend. When you get the response from your server, simply update theoptionsprop. The list inside multiselect will refresh automatically.If you want to show a loading indicator while the request is made – just change the
:loadingprop to true for the time between the request and the response.That’s all :)