I am new to Meteor and trying to add a button click event inside a Meteor template. I want to get the button id(accountId) using the class name. Below is my simplified html and javaScript:
HTML:
<template name="accountList">
<table class="table table-hover table-responsive">
<thead>
<tr>
<th>Id</th>
<th>Email</th>
<th></th>
</tr>
</thead>
<tbody>
{{#each accountDetails}}
<tr>
{{#with profile}}
<td>{{Id}}</td>
<td>{{email}}</td>
<td><button type="button" value="{{accountID}}" class="edit_button btn btn-default">Edit</button></td>
{{/with}}
</tr>
{{/each}}
</tbody>
</table>
</template>
javaScript:
Template.accountList.events({
'click .edit_button': function(){
alert(this.value);
//var selectedAccount = this.value;
//Session.set('selectedAccount', selectedAccount);
}
});
When clicking the edit buttons, I am getting an alert saying "undefined". I saw a similar question, but it is not working for me. Tried this method also, same output. Is there any other Meteor way to implement this? Any help?