Skip to content Skip to sidebar Skip to footer

Meteor : Remove Is Not A Function

I would like create global function to remove an item from my collection in Meteor. My code : Template.adminLayout.events({ 'click .delete': function(e) { var collecti

Solution 1:

Your collection parameter is a string with the collection name, not the collection itself. You need the actual collection object to perform data operations. If you want to be able to access collection by name, you need to prepare a dictionary yourself. For example:

Collections = {};

Collections['Documents'] = Documents = new Mongo.Collection('documents');

Then you can use it in your event handler:

var collection = Collections[$(e.currentTarget).data('collection')];

By the way, it's good practice to use e.currentTarget instead of e.target. It always get you the element you expect, while e.target can be one of its descendants.

Post a Comment for "Meteor : Remove Is Not A Function"