Hi,
I got a template where i fill an html table with element from my database, like this :
<table class="table table-hover table-condensed table-bordered">
<tbody>
{{#each proj in Project}}
<tr><td class="{{isSelected proj._id}} eSelectProj text-center" id='{{proj._id}}'>
{{proj.Title}}
</td></tr>
{{/each}}
</tbody>
</table>
I would like to be able to select one of the row, so i tried to refer them using id field ( id=β{{proj._id}}β ).
I catch click on a row like this :
Template.index_projet_admin.events({
'click .eSelectProj' (event) {
var project = {_id: event.target.id, title: event.target.outerText};
Template.instance().dict.set('selected', project);
}
});
And i would like to higlight selected row using an helper like this :
Template.index_projet_admin.helpers({
isSelected(id)
{
var selected = Template.instance().dict.get('selected');
return (selected !== undefined && selected._id === id) ? "active" : "";
}
});
But that dosenβt works.
So using console.log I figured that when i call {{isSelected proj._id}}, i got id as an ObjectID() containing a field str which is the id of my element. But when i fill the id field with id=β{{proj._id}}β i got a string like "ObjectID(βmyidβ¦β).
So how should i do to get it works ?
Thanks fo your time and your help !