Reputation: 4132
I need the append-icon="close"
to call @click="clearSearch()"
Right now I'm implementing it with a dedicated button:
<v-text-field
v-model="search"
class="search"
label="search"
prepend-icon="search"
append-icon="close">
</v-text-field>
<v-btn @click="clearSearch()"></v-btn>
append-icon-cb="clearSearch()"
but it doesn't work and I don't know whyclearable
, it clears the input but all the elements stay "filtered". I don't know how clearable
works but my clearSearch()
method simply does: clearSearch() {this.search = ""}
and it works, that's why I use the custom clear input methodUpvotes: 28
Views: 39302
Reputation: 593
for vuetify3 can define event based on inner icon or outer
<v-text-field
...
@click:append-inner="fx"
@click:append-outer="fx">
</v-text-field>
Upvotes: 0
Reputation: 31
This changed though:
For append icons e.g
append-icon="mdi-magnify-plus-outline"
,
you just do @click:append="zoomIn"
.
But for append outer icons like append-outer-icon="mdi-plus-circle-outline"
,`
you must add the word append i.e
@click:append-outer="addMore"
therefore, this will work with Vue2
<v-text-field
solo
append-outer-icon="mdi-plus-circle-outline"
@click:append-outer="addMore"
>
</v-text-field>
Upvotes: 3
Reputation: 817
Use @click:append="clearSearch"
, :append-icon-cb
is deprecated. (Source)
Upvotes: 48
Reputation: 2206
Just Change :append-icon-cb="() => (e1 = !e1)"
to @click:append="() => (e1 = !e1)"
and this will work perfectly and remove the warning too...
Upvotes: 1
Reputation: 19002
I think it should work if you remove ()
, because with ()
included, you immediately just call function once.
Edit: don't forget colon :
So:
:append-icon-cb="clearSearch"
Upvotes: 2
Reputation: 4132
To avoid that problem you should bind the attribute with :
symbol:
:append-icon-cb="clearSearch"
And don't put ()
otherwise it will not work (as @Traxo mentioned)
Upvotes: 6