Meteor method RangeError: Maximum call stack size exceeded


#1

when I invoke tasks.remove method I get this error
Exception while simulating the effect of invoking 'tasks.remove' RangeError: Maximum call stack size exceeded(…)
what’s in the method is here https://github.com/roberto68/pantryApp/blob/meteor-pantry/imports/api/tasks.js
, well nothing “unusal” - I’m just checking which todos (items) are checked and I only want to delete those.


#2

The problem is here:

You are passing a cursor (the result of Tasks.find) to the remove method. I would suggest the following:

Tasks.find({checked: true}).forEach(doc => {
  Tasks.remove(doc._id);
});

#3

thanks it works but here comes my second question how is it possible to implement radio button - cause each item has radio button in its html file - and that way I can choose as many as I wish ( that’s not desired functionality of radio button). You know it’s the classical todos example code. Or i.e how pass task’s id to radio button ??
`

    {{#each tasks}} {{> task}} {{/each}}
` you know

#4

If you put the <input>s into their own template, you get direct access to their _ids in your events. BTW - from your description I think you need type="checkbox":

<template name="tasks">
  <ul>
    {{#each tasks}}
      {{> task}}
    {{/each}}
  </ul>
</template>

<template name="task">
  <li>
    <input type="checkbox" checked="{{checked}}" class="toggle-checked" />
  </li>
</template>

Template.tasks.helpers({
  tasks() {
    return Tasks.find();
  }
});

Template.task.events({
  'click input'() {
    Tasks.update(this._id, { $set: { checked: !this.checked } });
  }
});