Autocomplete Vue


Topic: Autocomplete Vue

eladhr83 asked 5 years ago

Expected behavior v-model should always hold the text written on the input,

Actual behavior v-model only get updated when typing the value that is in the list

Resources (screenshots, code snippets etc.) states[] = { "United States", "Germany", ....} The user types blahblah The value in state is the previous legal field or empty if it started empty


Magdalena Dembna staff premium answered 5 years ago

Hi, The mdbAutocomplete component by default is meant to allow the user to enter only values from the provided list - so the inability to enter 'blahblah' in the country field is intentional. If on the other hand, you want to handle other values as well, use @input.native instead of v-model .

<mdb-autocomplete
  icon="heart"
   :data="states"
    label="What is your favorite US state?"
   @input.native="updateValue"
/>

updateValue(e) {
      this.autocompleteValue = e.target.value;
    },

Best regards, Magdalena


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
  • User: Free
  • Premium support: No
  • Technology: MDB Vue
  • MDB Version: 6.3.0
  • Device: PC
  • Browser: Chrome
  • OS: Ubuntu
  • Provided sample code: No
  • Provided link: No