Skip to content

Instantly share code, notes, and snippets.

@dillongreen
Last active January 2, 2016 15:48
Show Gist options
  • Save dillongreen/8325484 to your computer and use it in GitHub Desktop.
Save dillongreen/8325484 to your computer and use it in GitHub Desktop.
rather than jusing jQuery etc. one can use a template instance method such as find http://docs.meteor.com/#template_find
Template.application_security.events({
"click #requirementAdd": function (evt, templ) {
var requirement = templ.find("#requirementText").value;
var motivation = templ.find("#motivationText").value;
var example = templ.find("#exampleText").value;
var technology = templ.find("#technologyText").value;
Requirements.insert({
requirement: requirement,
motivation: motivation,
example: example,
technology: technology,
votes: 0,
email: getCurrentEmail(),
upvoters: [Meteor.userId()]
});
},
"click .upvote": function (evt, templ) {
Requirements.update(this._id, {
$inc: {votes: 1},
$addToSet: {upvoters: Meteor.userId()}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment