element icon indicating copy to clipboard operation
element copied to clipboard

El-autocomplete concatenate with previous field value instead of replacing it

Open abanghendri opened this issue 3 years ago • 1 comments

Hello, I use autocomplete element to provide autocomplete in my vue app, let say I use it for autocomplete Authors I need to fill multiple author with comma as delimiter first search query is OK image then, I add ", " to it and search for another author image but when I select the author from dropdown, the field is replaced by new value what I need for final value is "Ressie Bashirian, Dorris Kling"

How to achieve this?

I've tried using this

handleSelect(item) {
      console.log(this.model.authors);
      if (this.model.authors == null) {
        this.model.authors = item.name;
      } else {
        this.model.authors = `${this.model.authors} ${item.name}`;
      }
      console.log(this.model.authors);
    }

and this is my element

<el-autocomplete
        v-else
        v-model="model[field.name]"
        :hide-loading="true"
        :id="field.name"
        :fetch-suggestions="authorSearch"
        :trigger-on-focus="false"
        :placeholder="field.help_text ? field.help_text : field.label"
        @keydown="model.response.clearErrors($event.target.name)"
      >

but it doesn't work

abanghendri avatar Jun 08 '22 06:06 abanghendri

I am having a similar problem, I added the @input event to do it, although the value of the handleInput method arrives correct it does not change the v-model value.

EdwinBetanc0urt avatar Jun 02 '25 23:06 EdwinBetanc0urt