I am a student and I am working on a personal project on Meteor.
I have an item list retrieved from my MongoDB database in my template.
I would like to be able to retrieve the ID of each element from a function in a Meteor.call to assign an action related to a button.
Template
<template name="correction_accepted_list">
{{#each correction in corrections}}
{{> correction_single correction=correction}}
{{/each}}
</template>
<template name="correction_single">
<div class="card my-2">
<div class="card-body">
{{correction.status}}
<h5 class="card-title">{{getUserFullname correction.ownerId}}</h5>
<p class="card-text">{{correction.content}} {{correction._id}}</p>
<button class="js-accept-correction">Accepter</button>
<button class="js-refuse-correction">Refuser</button>
</div>
</div>
</template>
Fonction
'click .js-accept-correction'(event, instance){
Meteor.call('acceptCorrection', Corrections.find()._id,
(err, res) => {
if(!err) console.log('accepted!')
})
},
You can see the result on: http://52.47.162.25/
I use findOne () on the deployed version to have a small result but not the desired one.
I understand my mistake because I do not give any instructions to get the id of the targeted element, but I do not know how to do it for that.
Understanding how to do it would help me for many other things.