Skip to content
Permalink
Browse files

Grey out upvote link when not logged in / already voted.

chapter13-2
  • Loading branch information
tmeasday committed Oct 19, 2015
1 parent ee969bc commit a6943412644b733ad4e17b3fd3f2c3b01df56bae
Showing with 10 additions and 2 deletions.
  1. +1 −1 client/templates/posts/post_item.html
  2. +9 −1 client/templates/posts/post_item.js
@@ -1,6 +1,6 @@
<template name="postItem">
<div class="post">
<a href="#" class="upvote btn btn-default"></a>
<a href="#" class="upvote btn btn-default {{upvotedClass}}"></a>
<div class="post-content">
<h3><a href="{{url}}">{{title}}</a><span>{{domain}}</span></h3>
<p>
@@ -6,11 +6,19 @@ Template.postItem.helpers({
var a = document.createElement('a');
a.href = this.url;
return a.hostname;
},
upvotedClass: function() {
var userId = Meteor.userId();
if (userId && !_.include(this.upvoters, userId)) {
return 'btn-primary upvotable';
} else {
return 'disabled';
}
}
});

Template.postItem.events({
'click .upvote': function(e) {
'click .upvotable': function(e) {
e.preventDefault();
Meteor.call('upvote', this._id);
}

0 comments on commit a694341

Please sign in to comment.
You can’t perform that action at this time.