Is there a way to implement a @click event on a Vuetify expansion panel?

Whenever I use <a>, the design of the <v-btn> expansion panel breaks. How can I incorporate the click event in this situation?

I attempted to utilize filters, watch, and computed, but it didn't work.

Here's my code:

 <v-card xs12 sm6 md12>
         <template v-for="item in activityitems">
              <v-layout v-bind:key="item.ActivityID">
                     <a @click="activityList(item.ActivityID)">
                        <v-expansion-panel>
                           <v-expansion-panel-content>
                               <template v-slot:header>
                                    <v-card flat>
                                       <v-card-title>
                                        <span class="grey--text">
                                              Name:{{item.ActivityName}}
                                        </span>
                                       </v-card-title>
                                     </v-card>
                                     <v-card flat>
                                        <v-card-title>
                                          <span class="grey--text">
                                              Date:{{item.ActivityDate}}
                                          </span>
                                         </v-card-title>
                                      </v-card>
                                  </template>
                             </v-expansion-panel-content>
                         </v-expansion-panel>
                       </a>
                 </v-layout>
          </template>
</v-card>

Answer №1

One way to handle events is by passing @click directly to the <v-expansion-panel> tag

Check out this example on CodePen:

https://codepen.io/gonjeshk/pen/MWWPveX?editors=1010

<div id="app">
  <v-app id="inspire">
    <v-expansion-panels>
      <v-expansion-panel
        v-for="(item,i) in activityitems"
        :key="i"
        @click="activityList(item.ActivityID)"
      >
        <v-expansion-panel-header>{{item.ActivityID}}</v-expansion-panel-header>
        <v-expansion-panel-content>{{item.ActivityName}}</v-expansion-panel-content>
      </v-expansion-panel>
    </v-expansion-panels>
  </v-app>
</div>
new Vue({
  el: '#app',
  data: {
    activityitems: [
      { ActivityID: "Learn JavaScript", ActivityName: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' },
      { ActivityID: "Learn Vue", ActivityName: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit ullamco laboris nisi ut aliquip ex ea commodo consequat.' },
      { ActivityID: "Play around in JSFiddle", ActivityName: 'sed do eiusmod tempor aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' },
      { ActivityID: "Build something awesome", ActivityName: 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' }
    ]
  },
  methods: {
    activityList: function(id){
        console.log(id)
    }
  },
  vuetify: new Vuetify(),

})

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

Material-UI: The `paperFullWidth` key passed to the classes prop is not supported within the WithStyles(ForwardRef(Dialog)) component

When using Material-UI, please note that the key paperFullWidth provided to the classes prop is not implemented in WithStyles(ForwardRef(Dialog)). You are only able to override one of the following: root. <Dialog classes={{ paperFullWid ...

Response from Vimeo's AJAX API

I am having trouble retrieving the AJAX response from Vimeo to extract a thumbnail without using JQuery. Even though I can see the response data in JSON format when I type the response query (http://vimeo.com/api/v2/video/30408418.json) into the browser an ...

Click on the button to send the input field

Below you'll find an input field and a button: <input id="pac-input" class="controls" type="text" placeholder="Search! e.g. Pizza, Pharmacy, Post office"> <button id="new" class="btn btn-success">Submit</button> Currently, when te ...

What about a sliding element feature?

Is there a popular slider component that many startups are using, or are these types of sliders typically built from scratch? It seems like they are everywhere on startup websites. I would appreciate it if someone could point me in the right direction with ...

"Exploring the power of Knockout JS by utilizing the foreach loop to iterate through

I have an observableArray: self.stats = ko.observableArray([ {"DFTD" : new Stat("Defensive TD", "DFTD",0,20,0,self.playerGroups[1])}, {"GL" : new Stat("Games Lost", "GL",0,16,0,self.playerGroups[2])}, {"FGA" : new Stat("Field Go ...

Is there a way to identify the browser version that is being used?

I've been on the lookout for a specific code snippet that can help me identify whether the user visiting my website is using Firefox 3 or 4. Thus far, I have only come across code to determine the type of browser without indicating the version. Is th ...

Implementing onbeforeunload event on body tag with jQuery for Chrome and IE browsers

My current system includes a feature where I need to confirm with the user if they really want to leave the page once a dirty flag is set. I have implemented the following code - when viewing in Firefox, I can see that the page source shows the onbeforeun ...

Trouble getting Fontawesome icons to accept color props when using react functional components with tailwindcss

Issue I'm Facing I'm currently working on a project that involves using icons extensively. Instead of manually adding a Fontawesome icon in every script, I have created a functional component that handles the rendering of icons based on given pr ...

Using jQuery to deactivate buttons upon submission or clicking within forms and hyperlinks

Within my Rails application, there are buttons that send data to the server. Some of these buttons are part of a form while others are standalone. I am seeking a solution to implement my jQuery code, which disables the buttons upon click, for both scenario ...

Enhancing transparency with a touch of background color

After successfully exporting my chart created in canvas as an image file, I noticed that the image turned out to be transparent without any background. Is there a way through code to add a background color to this existing image obtained from canvas? For ...

Add the child element to the $slot.default

I have a situation where I need to implement a custom modal in my component but I am not sure where to place the dialog content. To tackle this issue, I came up with the following approach: <template> <div class="ComponentItself"> ...

Sending data to the server using the $.post method with an

I am having some trouble creating a post using a customized model: public class CallbackPriorityItemModel { public int userID { get; set; } public int order { get; set; } public string name { get; set; } } Unfortunately, I can't seem to ...

What is the best way to add child elements to existing elements?

When it comes to creating elements with jQuery, most of us are familiar with the standard method: jQuery('<div/>', { id: 'foo', href: 'http://google.com', }).appendTo('#mySelector'); However, there ar ...

The TypeError encountered when using vue.js push arises from attempting to access the 'name' property of an undefined value

Here is a code snippet I am working with: new Vue({ el: '#core', data: { checkedThemes: [] ... } }) Afterwards, I have the following code: mounted() { ... var theme = parseInt(parameters['theme&apo ...

Is there a way to transfer the input value from a textfield in one component to another component in ReactJS?

I have a scenario where I need to pass the value of a text area from one component in reactjs to another. The component's value is stored using a useState hook in the first component, and I want to access it in another component to run a map() functio ...

Ways to verify the identity of a user using an external authentication service

One of my microservices deals with user login and registration. Upon making a request to localhost:8080 with the body { "username": "test", "password":"test"}, I receive an authentication token like this: { "tok ...

Pagination Component for React Material-UI Table

I am interested in learning about Table Pagination in React UI Material. Currently, my goal is to retrieve and display data from an API in a Material UI Table. While I have successfully implemented some data from the API into the Material UI Table, I am ...

constructing a nested container using XMLHttpRequest

I am working on creating a nested div-container structure using AJAX and adding the text "Hello World" to the inner container. The outer container serves as a holder for the inner container in this case. Below is the code I have written: index.html: ...

Tips for executing a <script> whenever the properties of a component are modified

Can I automatically run a <Script/> every time the props of a react/nextjs component change? I'm currently converting markdown files to HTML using marked and, before rendering the HTML, I want to include a [copy] button on each <pre> bloc ...

Synchronous execution in Node.js: Best practices for coordinating tasks

While Node.js is known for its asynchronous nature, I am seeking to perform tasks in a sequential manner as outlined below: 1. Make an API request > 2. Convert the body from XML to JSON.stringify format > 3. Pass the string to a template. request.g ...