post_item.js 428 B

12345678910111213141516171819
  1. Template.postItem.helpers({
  2. ownPost: function () {
  3. // Template is invoked in the context of a Post, so 'this' is a Post.
  4. return this.userId === Meteor.userId();
  5. },
  6. domain: function () {
  7. var a = document.createElement('a');
  8. a.href = this.url;
  9. return a.hostname;
  10. }
  11. });
  12. Template.postItem.events({
  13. 'click .upvote': function (e) {
  14. e.preventDefault();
  15. Meteor.call('upvote', this._id);
  16. }
  17. });