I'm trying to figure out how to add a new collection each time a button is pressed. I have this html:
html:
<template name="tempName">
<button class="submitButton">Submit</button>
</template>
javascript:
Template.tempName.events({
'click .submitButton': function() {
count += 1;
Npm.newCol = new Mongo.Collection("NUM:" + count);
Npm.newCol.insert({
field1: "field1 contents",
field2: "field2 contents"
});
}
});
This does absolutely nothing, as far as I can tell. If I put all the contents from the .submitButton click event at the top of the js file (outside of the "if (Meteor.isClient)"), then it works perfectly. But I would like a new collection to be created each time a form is submitted. Does anyone know how to accomplish this?