Vue versions:
"vue": "^2.5.17",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
Background:
This is for a game I'm building.
The page is simple with two <select> drop down selection elements.
The second <select> element's <options> are dynamic from an API request, and depend on which option is being used from first element along with a conditional test using a getter on the Vuex store.
The Problem
When I toggle the currency type menu, and then toggle it back to the original setting, the second <select> is no longer bound to the value it should be as shown in the Vuex store.
The Price. currency remains: "USD" but when toggled back, the select menu looses this binding and displays blank.
<label for="currency-type">Choose currency type: </label>
<select id="currency-type" :value="Price.currencyType" @input="setCurrencyType">
<option
v-for="item in Price.availableCurrencyTypes"
:value="item"
>{{item}}</option>
</select>
<label for="currency-selection-dynamic">Choose a currency [dynamic]: </label>
<select id="currency-selection-dynamic" :value="Price.currency" @input="setCurrency">
<option
v-for="item in this.getAvailableCurrencies"
:value="item.currency"
>{{item.currency}}: {{item.label}}</option>
</select>
Desired Outcome:
I want to be able:
- to toggle between the currency types in the first
<select>and for the value stored in the Vuex store to still be selected when I toggle back. - to expect it to be binded, as the vuex store still says
Price.currency = "USD", and the<select>is bound using the:valueso I believe it should be selecting theUSDoption but its not. So it seems the binding is not being rendered in the browser.
I hope that you can understand this issue. I think it will really be easier for you to look at the repo and run it to see what I am on about here!
Any help would be greatly appreciated as I've been struggling with this for days now.