What causes the Vuetify checkbox to trigger twice when clicked in a Vue.js application?

I am facing an issue with a table that contains checkboxes in every row. I want to trigger some logic when a checkbox is clicked. In some cases, I need to tick multiple rows when a checkbox is clicked, so I have set the checkboxes as readonly and handle their selection in the script section. Below is my table structure:

     <div
        v-for="file in files"
        :key="file.entry.name">
        <v-list-item style="height: 40px;">
          <v-list-item-content class="text-left">
            <div class="wrapper">
              <div class="checkbox">
                <v-checkbox
                  readonly
                  @click="selectCorrespondingFiles"
                  v-model="file.isSelected">
                </v-checkbox>
              </div>
              <div class="title">
                <v-list-item-title
                  style="font-size: 16px"
                  v-text="file.entry.name">
                </v-list-item-title>
              </div>
            </div>
          </v-list-item-content>
        </v-list-item>
        <v-divider></v-divider>
      </div>

However, I noticed that my method is being called twice whenever I click on a checkbox:

    selectCorrespondingFiles() {
      console.log('selectCorrespondingFiles');
      ....
    },

I cannot figure out why the code is executing twice on each click. Any assistance would be greatly appreciated.

Answer №1

Experiment with

@click.stop="selectCorrespondingFiles"

Executing this will prevent successive calls and ensure only one function is invoked at a time.

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 Bootstrap Modal for efficient AJAX saving of multiple records with the help of bootstrapValidator

I'm encountering an issue with a bootstrap modal form and validation using bootstrapValidator. The problem I'm facing is that when I open the modal, fill out the fields, close it, reopen it, refill the fields, and submit the form, my script inser ...

The post method is functioning properly in browsers such as Firefox, Internet Explorer, and Chrome; however, it is not working in the Edge browser

I am encountering an issue with a post method in the Edge browser. Even though I am able to receive responses for the same request in other browsers like Internet Explorer, Chrome, and Firefox, Edge seems to be not responding at all. Despite conducting a s ...

The TypeScript error states that the argument type 'string | undefined' cannot be assigned to the parameter type 'string'

Receiving TS error that says "Object is undefined" I am attempting to retrieve the "userid" from my headers. However, I keep encountering the error message "Argument of type 'string | undefined' is not assignable to parameter of type 'str ...

Arranging images next to each other using CSS and HTML

I've been trying to arrange four images side by side, with two on the top row and two on the bottom. I want to ensure they stay consistent across all browser sizes except for mobile. Here is what I have attempted so far: #imageone{ position: absol ...

Converting a tree structure from GraphQL to JSON format using JavaScript

I'm attempting to convert my client-side data from this structure: [{ id: 1, name: "dad", parent: [], children: [{ id: 2, name: "child1", parent: { parent: 1 } }, ...

Identifying when a user has inputted incorrect $routeparams

How can I restrict user input to only "id" as a query parameter in the URL? $scope.$on('$routeUpdate', function () { var id = $routeParams.id //check if user has entered any params other than "id". //if yes do someting }); I want ...

Attempting to run a .mov file in Vue results in a compilation error

To ensure compatibility with Safari users, a .mov file is required. However, in Vue: <video id="myvideo" autoplay muted loop playsinline > <source src="@/assets/01/output2.mov" typ ...

How to extract data from Facebook's JSON using Javascript

I am utilizing a JavaScript API to extract Facebook comments. After receiving the JSON result below, I'm wondering how I can unpack and utilize them on my webpage? { "id": "1234567891_2823098717038_3160191", "from": { "name": "U ...

Exploring the Depths of React by Cycling Through Arrays in Tabular Format

One issue I'm facing is that I have an array named paymentMethods which I'd like to iterate through in tabs. However, I seem to be struggling with the iteration part. To take a closer look at my code, please visit my codesandbox HERE <div& ...

Generate a random number to select a song file in Javascript: (Math.floor(Math.random() * songs) + 1) + '.mp3'

My current JavaScript code selects a random song from the assets/music folder and plays it: audio.src = path + 'assets/music/'+(Math.floor(Math.random() * songs) + 1)+'.mp3' However, I've noticed that sometimes the same trac ...

Invoke a function only once in a Node.js application

What is the best way to execute a method only once when starting a node application? I am considering placing it in server.js, the executable file of my application, but I'm unsure if this is the correct approach. Are there any other options I should ...

JavaScript overlay that does not interact with HTML elements directly

Currently, I am facing the challenge of implementing a javascript overlay upon page load without direct access to the html code. My only options are to upload .js and .css files. I have extensively searched for solutions, but as someone with limited exper ...

Using Vuetify to display text fields in a single row

Check out this Vue component template (View it on CODEPEN): <div class="some-class"> <v-form > <v-container @click="someMethod()"> <v-row> <v-col cols="3" sm="3" v-for="p in placeholders" ...

"Return to previous page" feature

I am having difficulty figuring out how to implement the "go back" function for the page. For instance, I have pages A, B, C, and D. The possible switching between pages is as follows: A -> (B <-> C) -> A or D -> (B <-> C) -> D (w ...

Tips for integrating external JavaScript libraries and stylesheets into a widget

I am currently working on developing a custom Javascript widget that requires users to insert specific lines of code into their web pages. This code will then dynamically add an externally hosted javascript file, allowing me to inject HTML content onto the ...

Retrieve the fully loaded webpage source code in Java as it is displayed by the browser

There are certain webpages that utilize JavaScript and AJAX calls to populate fields during or after the page has loaded. An example can be found at this link, where the content in a size dropdown box is filled using JavaScript. I am wondering if it is po ...

Troubles with DropDownList onChange event when selectedIndex is at 0

Hey there, I have a question that's been puzzling me. I have three security question dropdown menus on my ASPX page with JavaScript that removes and repopulates questions based on user selection. Everything works great when editing an existing profile ...

What is the best way to incorporate an immediately invoked function expression (IIFE) within the return statement of a React

I currently have a modal that pops up when the user clicks a button on my page and it's functioning perfectly: render() { return ( <div> <section> <button onClick={() => this.refs.simpleDialog.show()}> ...

Updating Vue.js template data

Here is the code snippet I am working with: Vue.component('greeting', { template: `<h1>{{ greeting }}</h1>`, data: function () { return { greeting: app.text } }, }); var app = new Vue({ e ...

Having trouble grasping the functionality of Javascript in this code (using Coffeescript and Commander in Node.js)

I'm facing some issues when using Commander in Node.js - the parseInt function doesn't seem to be working correctly in my code: commander = require 'commander' #parseInt = (str) => parseInt str #I attempted to add this line witho ...