I'm currently exploring ways to dynamically add a new collection every time a button is clicked. Here's the HTML snippet I have:
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"
});
}
});
Upon testing, it seems that this implementation doesn't yield the expected results. Moving all the contents from the .submitButton click event to the top of the js file (outside of the "if (Meteor.isClient)") resolves the issue, but I'm keen on creating a new collection each time a form is submitted. Any suggestions on how to achieve this?