Zeus
Zeus

Reputation: 331

Creating a dynamic search

I'm currently using Vuetify to create a datatable, I see with the search as you type it filters down to narrow the results based on what's type in. I'm curious how I can use the same search bar, so when I hit enter it'll actually take the value and rebuild the datatable using the same axios call but adding the params to the URL. I still want to be able to filter current results when typing and not hitting enter though. Is this possible?

Overall Im trying to create tags when searching. Users would have the ability to hit enter, rebuild the table, but see the value they entered as a tag. With also the ability to x out of it and delete to restore defaults.

Upvotes: 0

Views: 324

Answers (1)

drew kroft
drew kroft

Reputation: 916

Assuming you have a search input like this:

<v-text-field
          v-model="search"
          append-icon="search"
          label="Search"
          single-line
          hide-details
          v-on:keyup.enter="myFunction"
 ></v-text-field>

You can add the v-on:keyup.enter as above, then put your functionality in myFunction

In myFunction, you can say this.search to get the value of that, and you can do whatever you want with it.

Upvotes: 1

Related Questions