Chris Ian Chris Ian - 2 years ago 95
Javascript Question

this._id is not accessible to Iron controller in Meteor js. How to get the id?

I have this in my


{{#each todos}}
<li class="list-group-item">
{{ task }}
<button class="delete"> Delete</button>

and in the controller
I have this{
'click .delete': function () {'ToDos.delete',this._id);

Without Iron Controller I can access the id of the collection in the event using
but with this setup it has a null value. Any ideas how to get the id of the collection todo in the controller?

Answer Source

Do the follow.

DashboardController = RouteController.extend({
    template: 'layout',
    data: function () { return SomeCollection.findOne(); },
    waitOn: function() { return Meteor.subscribe('someCollection') }
  'click .delete': function () {
   console.log( sure if this works.'ToDos.delete',;

The key here its that we don't need the {{#each}}, you should use the data function to populate the template with data.

if you do the follow it will work.{
'click .delete': function () {
       console.log( //undefined
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download