I'm trying to get a hold of meteor still so there might be an easy answer to this and i'm hoping that is the case. I have this function which works and returns the correct id when my button is clicked.
$(document).ready(function(){
$("button").click(function(){
var selection = (this.id);
boardSpecs[0] = selection;
return boardSpecs;
});
});
I want to make this into a meteor click event, something like this.
Template.selectBoard.events({
'click button' : function (event) {
event.preventDefault();
var boardType = event.target.id;
Session.set('boardType', boardType);
alert(boardType);
}
});
This is the template where the button exists.
<template name = "selectBoard">
<div class = "container">
<div class = "boardCarousel">
{{#each boardList}}
<div class = "span1">
<div class = "thumbnail">
<img data-src = "{{source}}" alt = "placeholder" class = "img-rounded">
<div class = "something">
<h2>{{name}}</h2>
<p>{{description}}</p>
<button type = "button" id = "{{id}}" class = "btn btn-primary">Select</button>
</div>
</div>
</div>
{{/each}}
</div>
</div>
console.log(event.currentTarget.id)? - rivarolle