I've created a template with the following structure:
<template name="drink">
<button class="btn btn-block{{isActive _id}}" data-drink-id="{{_id}}" data-vote-for="{{voteFor}}">{{name}}</button>
</template>
My helpers and events are set up like this:
Template.drink.events({
"click button": function(event) {
event.preventDefault();
Session.set(Session.get("activeChar"), $(event.target).data('drink-id'));
}
})
Template.drink.helpers({
isActive: function(id) {
console.log("id: " + id);
console.log("session: " + Session.get(Session.get("activeChar")));
return (id == Session.get(Session.get("activeChar"))) ? " btn-positive" : "";
},
voteFor: function() {
return Session.get("activeChar");
}
})
The resulting output is as follows:
id: 5668f7dc4b44184781b57abc
session: ObjectID("5668e94f4b44184781b57abb")
id: 5668e94f4b44184781b57abb
session: ObjectID("5668e94f4b44184781b57abb")
Why am I getting a string ID when using the helper, but an ObjectID when referencing the variable directly as {{_id}}
?