Skip to content

Instantly share code, notes, and snippets.

@czbaker
Created March 5, 2015 17:02
Show Gist options
  • Save czbaker/31051ff1378905ad42ae to your computer and use it in GitHub Desktop.
Save czbaker/31051ff1378905ad42ae to your computer and use it in GitHub Desktop.
Template.groupsNew.events({
// Submit the form
'click #submit': function(event) {
// Prevent default submission behavior
event.preventDefault();
// Fetch values from form
var theName = $("#name").val().trim();
var theDesc = $("#desc").val().trim();
var theURL = $("#url").val().trim();
var theTags = $("tags").val().trim().split(",");
// Construct document
doc = {
name: theName,
desc: theDesc,
url: theURL,
tags: theTags,
ranks: [
{
order: 1,
name: "Leader"
},
{
order: 2,
name: "Officer"
},
{
order: 3,
name: "Member"
}
],
roster: [
{
user: Meteor.userId(),
rank: 1
}
]
}
Meteor.call(addGroup(doc));
}
});
// Methods - Groups
Meteor.methods({
addGroup: function(doc) {
var id = Groups.insert(doc);
console.log("Added group with ID#" + id + " to database. (" + doc.name + ")");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment