I'm new to vue.js and have this list of items:
<div class="jokes" v-for="joke in jokes">
<strong>{{joke.body}}</strong>
<small>{{joke.upvotes}}</small>
<button v-on:click="upvote"><i class="fa fa-arrow-up grey"></i></button>
<div>
I want to toggle the grey to green when user clicks upvote button, so that the user knows what jokes she upvoted.
in the methods I have:
data () {
return {
jokes:[], //filled dynamically by calling backend server
id: ''
}
},
methods: {
upvote: function(joke) {
joke.upvotes ++;
//how to toggle grey to green here?
}
}
How can I achieve this? I have tried different tricks but all the tutorials change the class ALL of the items, not the one up-voted.