Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138279

Get a object data with click in v-for Div

$
0
0

I have a div with v-for and i want get the object value which div i clicked. I tried to show in data when i click the div with alert but it didn't work. Can you help me to solve this situation.

<div id="ticketContent" v-for="ticket in tickets" @click="getTicketInformations">
              <h5> Ticket : {{ ticket.ticketID }}</h5>
              <p>Ticket Number : {{ticket.ticketNumber}}</p>
              <p>Start Date : {{ticket.startDate}}</p>
              <p>Expire Date : {{ticket.expireDate}}</p>
              <p>Hours : {{ ticket.hours }} </p>
            </div>

state : {
   tickets :[
            {"ticketID":1001,
            "ticketNumber":"2783sA",
            "startDate":"05/10/2018",
            "expireDate":"10/21/2022",
            "hours":"08:00-22:00"},
            {"ticketID":1002,
            "ticketNumber":"8a210j",
            "startDate":"01/03/2018",
            "expireDate":"01/03/2020",
            "hours":"14:00-18:00"},
            {"ticketID":1003,
            "ticketNumber":"L90Np1",
            "startDate":"10/01/2015",
            "expireDate":"10/01/2020",
            "hours":"10:00-20:00"},
            {"ticketID":1004,
            "ticketNumber":"L90Np1",
            "startDate":"05/01/2015",
            "expireDate":"05/01/2016",
            "hours":"15:00-23:00"}],
}
<script>
import { mapGetters } from 'vuex';

export default {
    computed: {
      ...mapGetters({
        tickets : 'tickets'
      }),
    },
    methods : {
      getTicketInformations(){
        alert(ticket)
      }
    }
}
</script>

Viewing all articles
Browse latest Browse all 138279

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>