Created
March 5, 2015 17:02
-
-
Save czbaker/31051ff1378905ad42ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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