Multi select cleared after select
See original GitHub issueHi, In my component I pass via props data for multi-select when I tried to select other data my select whas cleared fully :
<template>
<div>
<b-form-group label="Rôle: ">
<b-form-select
@change="emit"
class="mb-3"
v-model="value"
id="form_roles"
aria-describedby="choicesLiveFeedback"
:state="formState"
:multiple="true">
<option :value="null">Select options</option>
<option v-for="(role, index) in roles" :key="index" :value="role" >{{ role }}</option>
</b-form-select>
<b-form-invalid-feedback id="choicesLiveFeedback" :style="formStyle">
{{ state }}
</b-form-invalid-feedback>
</b-form-group>
</div>
</template>
<script>
export default {
name: 'UserRole',
props: ['value', 'state'],
data () {
return {
roles: [],
selected: [],
}
},
watch: {
value () {
// if (this.selected !== this.value){
// this.selected = this.value
// }
}
},
computed: {
formState () {
if (this.state !== undefined && this.state.length > 0) {
return false
}
},
formStyle () {
if (!this.formState){
return 'display: block'
}
}
},
methods: {
emit (event) {
this.$emit('input', [event])
}
},
created () {
// console.log(this.value);
this.$http.get('/api/rest/securtity/roles').then(
response => {
this.roles = response.body
}
)
}
}
</script>
at every test select was empty in view …
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (2 by maintainers)
Top Results From Across the Web
Quick way to clear all selections on a multiselect enabled ...
Simply find all the selected <option> tags within your <select> and remove the selected attribute: $("#my_select option:selected").removeAttr("selected");.
Read more >Selection options clear in multi-select after a selection is made ...
I am a beginner with React using react-select to list a bunch of account objects but my options list clears after any one...
Read more >How to Clear or (Delete ) Selected items in Multiselect ...
Forum Thread - How to Clear or (Delete ) Selected items in Multiselect Dropdown By Clicking on external Button? - ASP.NET Core -...
Read more >How to clear multiselect selections
Since I am handling the form submission in the javascript, I need to clear the previously selected items. Selected options should get unselected....
Read more >Angular ng-select - npm
When multiple = true, allows to set a limit number of selection. [hideSelected], boolean, false, no, Allows to hide selected items. [multiple] ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
to update parent object ? maybe ?
@darkiron Your implementation has some flaws. Make sure to check Vue documentation on how to create a custom component that works with
v-model
as you expect it. https://vuejs.org/v2/guide/components-custom-events.html#Customizing-Component-v-modelCheck my example below, hope this helps https://codesandbox.io/s/9zj7943prr