Cant get two-way value syncing to work
See original GitHub issueHow can i send the country key through the event and get the corresponding country selected. right now it just gets overwritten to a string.
<template>
<div>
<multiselect
:selected.sync="selected"
:options="options"
@update="updateSelected"
:searchable="true",
:close-on-select="true",
:allow-empty="false",
deselect-label="Can't remove this value"
key="key"
label="label"
placeholder="Select Country">
</multiselect>
</div>
</template>
<script>
import Multiselect from 'vue-multiselect'
export default {
components: { Multiselect },
data () {
return {
selected: null,
options: countries
}
},
methods: {
updateSelected (newSelected) {
this.selected = newSelected
// console.log(this.key);
}
},
events: {
'changeSelected': function (selected) {
this.selected = selected;
}
}
}
let countries = [
{'key' : 'AF', 'label' : 'Afghanistan'},
{'key' : 'AX', 'label' : 'Aland Islands'},
{'key' : 'AL', 'label' : 'Albania'},
{'key' : 'DZ', 'label' : 'Algeria'},
{'key' : 'AS', 'label' : 'American Samoa'},
{'key' : 'AD', 'label' : 'Andorra'},
...
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to Fix Google Authenticator Codes That Have Stopped ...
All you have to do is make sure your Google Authenticator app's time is synced correctly. Launch the app, tap the menu button...
Read more >Resolve sync issues in Mail and Calendar apps in Windows 10
Go to Start and open Mail. · At the bottom of the left navigation pane, select The Settings button · Select Manage Accounts....
Read more >Does Zapier support two-way syncing?
No. Zapier does not support two-way syncing between apps right now. Think of Zaps like one-way workflows. In certain scenarios, you can...
Read more >Fix common issues with 2-Step Verification - Google Support
Tip: If you requested multiple verification codes, only the newest one works. My Google Authenticator codes don't work. It may be because the...
Read more >Secure keychain syncing - Apple Support
New devices, as they sign into iCloud, join the iCloud Keychain syncing circle in one of two ways: either by pairing with and...
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
I guess you need to set the whole object not just the key. This is because the
:selected
prop expects an object it would find inside the:options
prop. If there is no way to broadcast the whole object to the child, try using thefind
array method.Also if this is just a wrapper component, what about passing the selected value and countries as props and skipping the
$broadcast
? In Vue 2.0$broadcast
it is already deprecated as it is considered a bad design. I guess one of the reasons for this is that you have to be very careful not to use thechangeSelected
event in any of the parent components.Happy to help! 😃