Is it possible for Vuetify autocomplete to be configured with multiple arrays?

Within this scenario, two separate data arrays are present for fruits and animals. Initially, when the user engages with the v-autocomplete component, the search bar will display a list of fruit data: ["apple","banana","kiwi"]. Upon entering text into the search bar, the fruit data will disappear and be replaced by animal data fetched from an API. Despite the presence of two distinct data arrays, only one item can be added to the Vuetify autocomplete at a time.

 <v-autocomplete 
  v-model="select" 
:items="fruits" 
:search-input.sync="search">

Considering this limitation, is there any possible solution to dynamically change the items array based on the user's input in the input field?

Answer №1

To enhance your fruit array, consider combining it with the search results retrieved from your API.

Imagine you maintain an array named items to store all results and another array named fruit specifically for fruits. Upon creating your component, you may merge the contents of fruit into items, like so: this.items = [...this.fruit].

Subsequently, when conducting a search and obtaining the results stored in an array called

results</code, you can update <code>items
to include the items in both results and fruit, as shown below:

this.items = [...this.fruit, ...this.results]

Vuetify appears to apply its own search algorithm post fetching search outcomes, thereby filtering out any fruit entries that do not match your query.

If interested, you can view a demo I created on Codepen here.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to efficiently handle insertion and updating of multiple rows in Laravel using arrays

Hey there, I'm currently facing an issue with multiple row insert or update. The update functionality is working perfectly fine, but I'm not sure how to go about inserting a new row within the update process. I just want to achieve the following ...

Make sure to invoke the navigate() function within a React.useEffect() hook, rather than calling it during the initial rendering of

I am new to ReactJS. When the page initially loads, I need to check if the state is null, and if it is, redirect to a different login Page Below is the code for the component: export default function Addblousesalwar() { const navigate = useNavigate(); ...

Is the express.json() middleware for parsing JSON request body designed to handle synchronous calls?

According to Express.js's documentation, it is recommended to avoid using synchronous functions as much as possible. This is because in high-traffic websites, the accumulation of synchronous calls can negatively impact the performance of the applicati ...

Choose the text value of the jQuery select menu from the specified column in the table

I need to search through all the select elements in a specific table column with the id "tdcities". I want to compare their ids with the row id and if there is a match, I need to select the text value. Below is the code I am currently using: $("#tdcities ...

Increasing counter on the backend using PHP or JavaScript

Having done my research, I am struggling to find a suitable solution for my project. I need a server-side incremental counter that resets daily. The goal is for every website visitor to see the same number on the counter. Is there a PHP script or JavaScr ...

What is the best way to dynamically identify the property names of my object?

let weekData = []; for (let i = 0; i < 7; i++) { const weekdayName = moment().subtract('days', i).format('dddd'); weekData.push({ [weekdayName]: 0 }); } I'm trying to create a list of objects with dynamic pr ...

Retrieve information using the request npm package

Currently, I am in the process of developing an application with express js. My approach involves using request(v-2.88.2) to retrieve data from an api. request(url, function(error, request, body) { var data = JSON.parse(body); }); My goal is to utili ...

Unable to activate the date range picker

I am having trouble with integrating the daterange picker on my webpage. I can't seem to get it to work properly. Can anyone help me figure out what I might be doing wrong or if there's something missing? CSHTML: <div class="has-feedback" &g ...

Warning from Vue Router: Issue with push/replace state - TypeError: history[(intermediate value)(intermediate value)(intermediate value)] is not a valid function

I've been working on setting up Vue Router (Vue 3 + Vue Router 4) and I'm facing some challenges with the following error messages: [Vue Router warn]: Error with push/replace State TypeError: history[(intermediate value)(intermediate value)(inter ...

"Utilize JavaScript to assign array values to the main object for efficient data

I am looking to parse a modified JSON file to create separate objects for each team and player. I want each object to have a key for the team name and the player name. Using JavaScript, how can I achieve the following structure: [ { name: 'Dallas St ...

Exporting functions using reactjs and babel

I'm currently working on a project that involves using reactjs, transpiled by babel with es2015 and react transforms configured in my .babelrc file. In the initial stages of refactoring, I realized that many of the classes should actually be functions ...

The extracted text from the window appears to be blank

When attempting to enclose a selected string between two characters, I am encountering an issue. For example, when selecting 'test' and clicking on the change button, the selected text should change to 'atestb'. However, although I am a ...

What is the most effective method to arrange absolute divs generated randomly in a grid-like formation?

Hey there! I'm facing an intriguing challenge with my app. It's designed to generate a variable number of divs which are always in absolute positioning. Unfortunately, making them relative is not an option due to some other factors within the app ...

Utilizing asynchronous false in Wordpress Ajax functionality

Is there a way to use the AJAX return value outside the function in WordPress? For example: function get_login_member($) { $.post(ajax_object.ajax_url, {action: 'getloginmember'}, function (data) { data = JSON.parse(data); ...

The issue with the autoresize feature in the tinymce plugin arises when trying to delete HTML img content using the backspace

When using the tinymce editor with the autoresize plugin enabled, I have noticed that it works correctly with text. However, there is an issue when inserting HTML content via execCommand. For example, if I insert the following code: <div> < ...

What is the best way to retain checkbox states after closing a modal?

I have a modal that includes multiple checkboxes, similar to a filter... When I check a checkbox, close the modal, and reopen it, the checkbox I clicked on should remain checked. (I am unsure how to achieve this :/) If I check a checkbox and then click t ...

The Data Table experiences intermittent hanging issues (Table is empty) when sorting or loading data with Knockout binding

While working on a project, I encountered an issue with binding data to a table using Knockout JS and the JQuery/Bootstrap based; Data Table API. The problem was that the table would become unresponsive at times when sorted or loaded, without any errors be ...

Fixing issues with Ajax calls in Internet Explorer versions 7 and 8

Here is the Javascript code I have written: $("#login").click(function(){ username=$("#user_name").val(); password=$("#password").val(); $.ajax({ type: "POST", url: "login.php", data: "username="+username+"&passw ...

Extjs: How to Select a Node After Creating a Tree Structure

I am facing an issue with my TreePanel where I want to preselect a specific node when loading it. The nodes are fetched from a remote json file and the tree structure loads correctly. However, the selected node is not getting highlighted and Firebug is sho ...

Iterate through an array of objects and add them to a fresh array

I am encountering an issue where I would like to generate a fresh array of objects in order to avoid utilizing a nested array map. However, the error message below is being displayed: TypeError: Cannot read property 'subscriber_data' of undefine ...