Is it possible to activate a click event on a v-select component?

I am currently using vue-select and I would like to create a click event when an item is selected from the select list. I attempted to use

@change="changedValue" @selected="changedLabel"
but it did not work as expected.

Vue Select

<v-select placeholder="Add administrator" class="form-control-select" label="displayName" :options="items"></v-select>

Is there anyone who knows how to trigger this event? Thank you

Answer №1

It appears that the component library being used was not specified, but based on the code provided, it seems to be vue-select.

Looking into the source code of this component, I found an onChange prop which is triggered when the selected value changes and by default emits the input event.

To link your changedLabel function with the input event, you can simply do the following:

Vue.component('v-select', VueSelect.VueSelect)

new Vue({
  el: '#app',
  data: {
    items: [      
      'foo',
      'bar'
    ],
    selected: null
  },
  methods: {
    changedLabel(event) {
      this.selected = event;
    }
  }
})
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a0c0f1f57091f161f190e3a48544e544a">[email protected]</a>/dist/vue-select.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6a1c1f0f2a58445f445b5c">[email protected]</a>/dist/vue.js"></script>
<div id="app">
  <v-select 
    placeholder="Add administrator" 
    class="form-control-select" 
    label="displayName" 
    :options="items"
    @input="changedLabel"
  ></v-select> 
  
  <span>{{ selected }}</span>
</div>

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

Utilizing a Custom Hook for Updating Components in useEffect

I am facing an issue with the following code snippet: function checklogin(callback) { if (!state.user.authenticated) pushhistory("/accounts/login", function(){teamhome2_message();}); else callback(); } // TRYING TO CONVERT IT INTO ...

Encountered a problem when constructing a Vue/Quasar application within a Docker

Error Message While Building Docker Image with Vue-cli-service During the process of containerizing my app for deployment on a cloud service using Kubernetes, I encountered an error specifically related to the vue-cli-plugin-quasar while running the build ...

Execute a task on Mobile Safari (after a delay)

I'm currently experimenting with HTML5 on Mobile Safari for iOS 6 and I'm curious about executing JavaScript code after a certain amount of time has elapsed. One specific task I am interested in is redirecting to a different page after 60 seconds ...

Exploring Ngrx: Leveraging a single selector to choose multiple property modifications

I need some help with my reactive Form Angular application that uses the NGRX store. Instead of subscribing to the entire state, I want to subscribe to changes in specific fields like "name" and "city." I have been attempting to use the selector selectFor ...

Merging an assortment of items based on specific criteria

I have the following TypeScript code snippet: interface Stop { code: string } interface FareZone { name: string; stops: Stop[]; } const outbound: FareZone[] = [{name: 'Zone A', stops: [{ code: 'C00'}] }, {name: 'Zone B ...

Contrasting the variance between binding through the [] syntax and abstaining

There is a unique custom my-table element that has its row property bound to the host component. There are two different ways in which HTML can be inserted: <my-table [rows]="displayEntriesCount"></my-table> and alternatively: <my-table r ...

Encountering issues with the functionality of the MUI Select component, causing the application to crash during

The issue has been successfully resolved I have been in the process of constructing a modal that includes a form and incorporating the MUI Select component. However, upon opening the modal, the application encounters an error; removing the Select componen ...

What happens when Image Buttons are clicked in SAPUI5 and their onchange event is triggered

Is there a way to update the image on a button after it has been clicked? I want it to switch to a different image when activated. var offButton = new sap.ui.commons.Button({ id : "offIcon", icon : "img/off.png" , press :functio ...

Data has been successfully acquired through the query, however, it cannot be accessed via the GraphQL API

After successfully building the API with Apollo Server and verifying its functionality in GraphiQL, I proceeded to make requests to the API from a front-end React app using Apollo Client. const [getUserPosts, { loading, error, data }] = useLazyQuery(GET_US ...

Creating a facade for multiple pipes in a Gulp task: A step-by-step guide

The task specified in my gulpfile.js looks like this: gulp.task('css', function() { return gulp.src('theme.scss') .pipe(...) .pipe(...) .pipe(...) .pipe(...) .pipe(...) .pipe(...) .pipe(gulp.dest('dis ...

What is the best way to retrieve all file names within the static folder in NuxtJs?

Currently, I am working with a frontend in NuxtJs and I have a requirement to display a list of all PDFs stored within the static folder. My goal is to create dynamic links that will allow users to open these documents in a separate browser window. There ...

Guide on retrieving URL data using Ajax

While I am familiar with the method in PHP (e.g. curl) to retrieve the contents of a URL, I am unsure of how to do so using ajax. Unfortunately, I have tried writing code without success in displaying the contents from the URL and separating them into vari ...

Front end development in Laravel 6.2 not coming together as expected

I've recently started using Laravel 6.2 and Vuetify, but I'm encountering an issue with Vuetify not working properly. The design for Vue.js does not appear as expected and I can't figure out what went wrong. Can someone please assist me with ...

Using expect() within the .then() function when writing Jasmine unit tests for AngularJS

I'm currently struggling with the .then() function while trying to implement Jasmine unit testing. Here is the code that's giving me trouble: describe("getBuilding", function () { it("checks getBuilding", function () { var id_building = 4; ...

The Architecture of a Node.js Application

I'm curious about the efficiency of my nodejs app structure in terms of performance optimization. My main concern lies in how I handle passing around references to my app object across modules. Basically, in my app.js file, I define all my dependenci ...

At what point is the args variable required by Dojo?

There comes a point when passing the args variable to an anonymous function in Dojo becomes necessary, even though the function itself may not visibly need it. This can lead to confusion as there is no clear indication on the Dojo help page regarding whe ...

Learning how to seamlessly integrate plugins such as routers, cookies, and more into your Vue3 project

Hello, I'm currently trying to migrate my entire Vue2 app to Vue3 and I'm running into numerous errors related to the 'this' keyword. The main issue is: this.$router.push({}); this.$route.params watch:{ "$route.path" : fu ...

Modifying the appearance of a Component within a NavLink

I'm currently working on a navbar using NavLink from React-Router-Dom. It's fine to use the 'isActive' prop to style the active Link, but I'm stuck on how to style the subelements inside it. For more specific details, please take a ...

Seeking a method to attach information from a div to a hyperlink

As a complete novice in the world of CSS websites, I find myself struggling to accomplish what seems like a simple task. I am working with an automatically generated CSS/JavaScript website where on the "individual" page, a person's name is listed with ...

Working with variables passed from Node.js in Jade processing

Currently, I have a situation where my script is sending a matrix that looks like this: [[1,2,3,4], [7,6,5,4], [2,3,4,5]]. After sending it using res.send(JSON.stringify(dataArray)); and viewing it in jade with h1#results, I can see that the format appears ...