comments.js 544 B

1234567891011121314151617181920212223242526
  1. /**
  2. * Client code for the comments template.
  3. *
  4. * - events
  5. */
  6. Template.comments.events({
  7. "submit .js-comment-submit": function (event) {
  8. const contents = event.target["comment-input"].value;
  9. const user = Meteor.user();
  10. const comment = {
  11. poster: {
  12. _id: user._id,
  13. name: user.username
  14. },
  15. contents: contents
  16. };
  17. const modifier = {
  18. $push: {
  19. comments: comment
  20. }
  21. };
  22. console.log(modifier);
  23. Websites.update({ _id: this._id }, modifier);
  24. return false;
  25. }
  26. });