vue-select
vue-select copied to clipboard
v-model is not updated when getting new data via ajax
I am using the component to get data from ajax, everything works fine until I realized that when returning via ajax one of the options with one of its different properties and selecting it does not update its status, for example:
"options": [ { "id": 21, "name": "phone", "price": "10.00" }, ... ]
previous
"options": [ { "id": 21, "name": "phone", "price": "30.00" }, ... ]
new
I use filters (external to the component) to receive different prices on each object, so these are different, but when selecting the value of the new arrangement, the data model is still seen as:
"selected": { "id": 21, "name": "vamke-Johnseye", "price": "10.00" }
so is this an expected behavior, or is it an internal component problem?
As I understand the flaw of this component that it is initialize the state only once, neither options
or v-model
represent reactive nature of the component. I have not found a way of applying new data with ajax without @search
which is totally wrong way for me :(
Try to hang watch on options
watch(options, () => {
if( props.selected){
selected.value = options.value.find((option) => option.id === props.selected.id);
}
});
"version": "4.0.0-beta.6"