Comments (3)
I should've read the closed issues first, my bad.. #28
from vue-select2.
Back with some more details.. because for some reason it doesn't work for me. After reading the issue tagged above, I switched from options to v-model
<Select2 @select="selectEvent($event, selectedValues.catToolsOptions)"
v-model="catTools"
:settings="{ multiple: true }"
:disabled='showReviewTab' />
vue data
data: function () {
return {
catTools: []
}
}
in mounted callback I am calling a method, that calls an API to get data for select
loadCatToolsOptions () {
let url = '/api/translators/cat_tools.json'
this.axios.get(url).then(response => {
# this is an action in vuex, to loop through all available options and mark the ones selected based on options from other component
this.setCatToolsOptions(response.data)
# assigning the data from store to this component model
this.catTools = this.catToolsOptions
})
},
In the end, my model has the following data
[{"id":1,"text":"TRADOS","selected":true},{"id":2,text":"ACROSS","selected":true},{"id":3,"text":"WORDFAST","selected":false},{"id":4,"text":"MemoQ","selected":false},{"id":5,"text":"Transit","selected":false},{"id":6,"text":"InDesign","selected":true},{"id":7,"text":"Omega","selected":false},{"id":8,"text":"SDLX","selected":false},{"id":9,"text":"Memsource","selected":false}]
which look like valid data for select2 component. But still, there are no preselected options. Even hardcoding the above Array of objects to catTools data model is not working. What am I doing wrong?
from vue-select2.
Ok.. for others who get into the same thing :)
v-model should hold the id's of preselected options, in my case catTools should have [1, 2, 6].
while options still holds the information about available options.
from vue-select2.
Related Issues (20)
- On Open not Focus on search filed HOT 2
- Why bootstrap theme doesn't have any effects on select2 component? HOT 1
- Missing usage of optgroup HOT 1
- vee-validate package v2 not working properly with vue-select 2
- Select two elements when one is chosen
- vue3-select2-component modal issue HOT 1
- Vue-Select2 not showing on result
- How to serverside query
- Vue.js 3 - problem jquery - does not provide an export named 'default' HOT 7
- modelValue as Number
- Custom Name Option Not Working
- Vue3-select2-modal problem. HOT 1
- Dropdown doesn't close when I use more than one select2 on a page event it remains in dom till press any click
- Multiple Select HOT 1
- @change not working
- selectionCssClass setting doesn't work
- Update proposal
- vue3-select2-component: select2 is not a function & Unhandled error during execution of mounted hook
- Paginate data options in select 2
- how can i add icons/image against every option?
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 vue-select2.