I'm a beginner and I'm working on a little exercice right now where I need to implement a function that will vote for a specific picture every time we click on the "Vote" button.
Here is what it looks like, for example if I click on the first button, I need to increment the number of vote for this picture. Here is what i did :
<div id="display" class="container">
<table class="w3-table-all" id="tableDisplay">
<tr>
<th>Cat</th>
<th>Vote</th>
</tr>
</table>
<div v-for="display in gridData">
<table class="w3-striped w3-table-all table table-bordered" id="tableDisplay">
<tr class="w3-hover-light-grey">
<th>
<img :src="display.url" height="200px" width="300px"/>
</th>
<th>
<button class="w3-button w3-green w3-hover-light-green"v-on:click="test(display.counter,display.id)" v-bind:id="display.id">Vote !</button>
</th>
</tr>
</table>
</div>
</div>
And the vueJs part :
new Vue({
el :'#display',
data: {
gridData :[
{
"url": "http://24.media.tumblr.com/tumblr_m82woaL5AD1rro1o5o1_1280.jpg",
"id": "MTgwODA3MA",
"counter" : 0
},
{
"url": "http://24.media.tumblr.com/tumblr_m29a9d62C81r2rj8po1_500.jpg",
"id": "tt",
"counter" : 0
}
],
},
methods:{
test: function(count,id){
count ++;
alert(count);
}
},
})
And the problem is that it doesn't update the change, in the "counter" section it still at 0.
Thank you for any help.

Aucun commentaire:
Enregistrer un commentaire