Blur event triggers on V-autocomplete without a value

How can I retrieve the selected values from a v-autocomplete upon blur event? Currently, the value $event.target.value always returns an empty string. As a workaround, I have been using the following code to split the parentElement's innerText:

var value = $event.parentElement.innerText;
value = value ? value.split('\n') : [];

This issue seems to occur only when the multiple prop is set in v-autocomplete:

<template v-slot:item.fieldName="{ item }">
  <v-autocomplete
    multiple
    small-chips
    :value="item.fieldName"
    :items="items"
    color="primary"
    @blur="updateItem(item, $event.target.value, 'fieldName')">
  </v-autocomplete>
</template>

I couldn't find any information on this issue. Is there a correct way to handle input in this scenario?

Answer №1

Have you experimented with utilizing a v-model? Implementing two-way binding in this scenario would eliminate the need to manually retrieve items using $event.target.value.

<v-autocomplete
            v-model="values"
            :items="items"
            dense
            chips
            small-chips
            label="Solo"
            multiple
            solo
          ></v-autocomplete>

You should then be able to access the data directly from the values field. You can refer to this link for more information: https://github.com/vuetifyjs/vuetify/blob/master/packages/docs/src/examples/v-autocomplete/prop-dense.vue

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

Setting up the html div to contain the three.js container

Within my article container, there are three aside tags. The third aside with id='menuPuzzleType' contains a Three.js script that creates and displays two cube meshes in a Canvas renderer. <article id="popup"> <aside id='close ...

Having trouble getting sweet alert to work with my PHP script

I’m integrating Sweet Alerts 2 into my webpage in order to prompt the user when trying to delete something. However, I'm encountering an issue where the PHP file is not being triggered when the user presses delete and the Sweet Alert does not appear ...

What is the process for rendering a Nested Component?

Let's develop a component that is used within another component on a webpage. Here's an example - MainComponent.tsx import NestedComponent from '../components/nestedComponent'; const MainComponent = () => { const { value, se ...

Execute Javascript/Jquery upon partial content loading

From what I can see, most of the examples and answers show how to run a partial's JavaScript when the page initially loads. In this case, the partial doesn't load until later, triggered by a button click using AJAX. I have experimented with pla ...

Timepicker Bootstrapping

I've been searching for a time picker widget that works well with Bootstrap styling. The jdewit widget has a great style, but unfortunately it comes with a lot of bugs. I'm on a tight deadline for my project and don't have the time to deal w ...

Tracking changes to payment methods when an order is modified through the WooCommerce backend

In the midst of working on a project involving WooCommerce, I am currently focused on integrating a new feature. This feature involves adding an order note whenever a user modifies the payment method during the order editing process within the WooCommerce ...

When an Array is rendered in Vue.js, it automatically binds inline style expressions

My concern is regarding the rendering of column width in a table. When the value of a circle in the rendering is set to style =" width: 200px ", but if the column width does not have a value assigned, it doesn't render. How can I solve this issue? &l ...

Error encountered in jQuery validation script due to incorrect data type

Looking to experiment with the jQuery validate plugin in an MVC application by trying a simple example. Here is a JS module with a method: ValidateRestriction: function (element) { var inputs = $('form').validator(); inputs.data("validat ...

Using an `<img>` element as an event handler in a JavaScript function

I'm having trouble setting up a click handler for the search field in my project. I've tried using on() with an img or class, but it's not working as expected. When adding the image using the code below: jQ('#psc').append('&l ...

Confirm that the Time sequence is accurate using JavaScript Selenium

I am working with a list of time intervals that includes 'a day ago, 10 days ago, 3 months ago, and 6 months ago.' How can I verify that these dates are in ascending order using JavaScript and Selenium? I am unsure of how to approach this proble ...

Do not fetch data again after a re-render

My code is facing an issue where every time I click toggle, the Child component re-renders and triggers another API request. My goal is to fetch the data once and then keep using it even after subsequent re-renders. Check out the CodeSandbox here! functio ...

Having trouble grasping this concept in Typescript? Simply use `{onNext}` to call `this._subscribe` method

After reading an article about observables, I came across some code that puzzled me. I am struggling to comprehend the following lines -> return this._subscribe({ onNext: onNext, onError: onError || (() => {}), ...

An object rotating in a loop with Three.js will not cast a shadow over the entire scene

Why are some cubes in my loop not casting shadows? Despite using a directional light that should cast shadows on all cubes, the shadowing stops after around 5 columns. let dirLight = new THREE.DirectionalLight(0xFFFFFF, 1.5); dirLight.position.set(300, - ...

Issue with AJAX request on Internet Explorer versions 8 and 9

This script is functioning properly in Internet Explorer 10 and above, as well as Chrome and other browsers. However, it encounters issues specifically with IE8 and IE9. <table id="table" border="1"> <tbody style="display: table-row-group"&g ...

Can I obtain page redirect data using Ajax?

Is there a way to detect URL redirects when making jQuery Ajax requests? For instance, if a request to http://api.example.com is redirected to http://api2.example.com in PHP, can this redirection be captured? Scenario: I am using AJAX to load pages into a ...

Using the v-model directive in Vue.js with a for loop is

I am facing a challenge where I need to implement a v-for loop with multiple components, but I am unsure how to add a unique v-model to each component that is generated within the loop. <template> <ProfilePasswordField v-for="(item, ind ...

Are there any available npm modules for accurately tallying the total word count within a document saved in the .doc or .doc

I Need to tally the number of words in doc/docx files stored on a server using express.js. Can anyone recommend a good package for this task? ...

Service in Angular JS dispatching coordinates to controller

I am in need of retrieving a path consisting of latitude and longitudes for displaying on a map within my app. To handle all the API calls, I have set up a basic controller. function mainController($scope, $http){ $http.get('/api/lastrun') ...

Karma glitch - Anticipated undefined to have a definition

Attempting to unit test my controller has presented some challenges. While basic test assertions using the expect API worked fine, I encountered an issue when trying to mock scope methods within a conditional check. An undefined error was thrown as the met ...

What is the best way to retrieve data from a jQuery AJAX call when it returns?

function isNewUsername(str){ var result; $.post('/api/isnewusername', {username:str}, function(data) { result = data.result; }, "json"); return result; } I am encounte ...