Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: MdbSelect - how to set default value?

Nommo pro asked 6 years ago


Hello. How is it possible to set default value for mdbselect in Vue?
<mdb-select v-validate="'required:country|len:2'" :data-vv-as='$t("addressPage.country")' v-model="formData.country" @getValue="getCountryValue" name="country">
  <option disabled selected>{{ $t("addressPage.chooseCountry") }}</option>
  <span v-for="(country, index) in countries" :value="country.code" :key="index">{{ country.name }}</span>
</mdb-select>
<label>{{ $t("addressPage.country") }}</label>

That's my code, adding options :selected="index === 2" doesnt work (it seems it sets selected for all options)

Jakub Mandra staff answered 6 years ago


Hello, Thank you for posting, we didn't know this issue. I found out that it is not possible to set 'selected' state inside v-for. It's because it read options data-attrs, so even if you ascribe :selected="false" it is still selected. Will fix that in next release.   Regards, Jakub

Nommo pro commented 6 years ago

Awesome thanks! :)

Nommo pro answered 6 years ago


Is it possible to get an answer?

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Vue
  • MDB Version: 4.5.1
  • Device: MacBook
  • Browser: Chrome
  • OS: MacOS
  • Provided sample code: No
  • Provided link: No