Comments (6)
@adamberecz hi, i have the same problem, when getting options asynchronously (render select with empty options and then update otions)
@v1r0x, hi! You can fix your problem by adding 'v-if=state.roles.length" to multiselect component
from multiselect.
Added a patch in 1.3.1
where nextTick
is no longer required.
from multiselect.
You're welcome @v1r0x, I'm glad you like it! I've tried this based on what's available (without store) and the initial value was loaded correctly:
<template>
<div>
<multiselect
v-model="value"
:label="'display_name'"
:track-by="'display_name'"
:valueProp="'id'"
:mode="'tags'"
:searchable="true"
:options="options"
:placeholder="'Placeholder'">
</multiselect>
</div>
</template>
<script>
import multiselect from '@vueform/multiselect'
export default {
components: {
multiselect,
},
data() {
return {
value: [1],
options: [
{ "id": 1, "name": "admin", "display_name": "Administrator", "description": "Project Administrator",
"created_at": "2017-12-20T09:47:35.000000Z", "updated_at": "2017-12-20T09:47:35.000000Z" },
{ "id": 2, "name": "guest", "display_name": "Guest", "description": "Guest User",
"created_at": "2017-12-20T09:47:35.000000Z", "updated_at": "2017-12-20T09:47:35.000000Z" }
]
}
}
}
</script>
<style src="@vueform/multiselect/themes/default.css"></style>
So I assume the issue is in the environment, which I cannot see in your example. You should create a complete example that produces the error in JSFiddle so that I can look into further.
from multiselect.
@alexeyolenikov Hey there! I actually thought I already tried that. But I think I did not 🙈 I'll try it next week. Thanks for the hint!
Edit: It actually works with v-if="state.roles.length"
! 🎉
If there's a way to show async options without v-if
this would be awesome! \m/
from multiselect.
I tried to set options and v-model on mount (jsFiddle). It does not work. The options are set, but the value is not set. Is it a bug? Or how can i set options and value(s) at once after a api request?
from multiselect.
With $nextTick it works!! See jsFiddle
from multiselect.
Related Issues (20)
- Blur when option have a lot in mac os
- Different clearIcon svg fill color for dark and light mode HOT 2
- focus() issue HOT 1
- Missing methods in Multiselect type
- Add focus/blur event emits HOT 1
- Clicking the clear icon
- Typescript Build Error HOT 1
- can't add option with space in mobile
- Opening disabled input
- Select does not scroll to selected item when the list is large HOT 2
- `getOption` does not work when `value` is an object. HOT 1
- Empty values in createOption with trimmed value HOT 1
- Prop `closeOnScroll` doesn't work with `appendToBody`
- Expose loading state on async options HOT 1
- appendToBody on async options: dropdown position is incorrect for the first time appearance HOT 1
- [Feature Request] Choose positioning for appendToBody
- Expose default search/filter function
- issue with :append-to-body="true" in a modal.
- In mode "Tags" with an array of objects, an error message should be shown when valueProp can not be found HOT 2
- Tags mode displaying tag count limit
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multiselect.