Vulcan/client/templates/post_single_trash.js
2012-09-06 10:14:03 +09:00

33 lines
897 B
JavaScript

Template.selected_post.events = {
'click input[type=submit]': function(evt){
evt.preventDefault();
var post = Posts.findOne(Session.get('selected_post_id'));
var $comment = $('#comment');
Meteor.call('comment', post, null, $comment.val());
$comment.val('');
}
};
Template.selected_post.show = function(){
return Session.equals('state', 'view_post');
};
Template.selected_post.show_comment_form = function(){
return Meteor.user() !== null;
};
Template.selected_post.post = function(){
var post = Session.get('selected_post');
return post;
};
Template.selected_post.has_comments = function(){
var post = Session.get('selected_post');
return Comments.find({post: post._id, parent: null}).count() > 0;
};
Template.selected_post.child_comments = function(){
var post = Session.get('selected_post');
return Comments.find({post: post._id, parent: null});
};