-
Notifications
You must be signed in to change notification settings - Fork 149
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
v-model value not respected on start #26
Comments
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. |
@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 |
@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 |
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? |
With $nextTick it works!! See jsFiddle |
Added a patch in |
Hey!
Thank you very much for this very easy to use and customizable component! 🎉
It works very well so far, except showing initial selected values. In the example below I load a list of users and their associated roles and a list of all roles as well.
The
user.role_ids
property is an array with only one value[ 1 ]
, but nothing is displayed in theMultiselect
component.When selecting one of the options in the Multiselect dropdown, the
user.role_ids
changes and the entry is displayed in the components div.But I can see no difference in the result in
user.role_ids
.Is there something I am missing or using the component the wrong way?
Example:
The text was updated successfully, but these errors were encountered: