【发布时间】:2015-07-26 10:38:30
【问题描述】:
如何在“讨论”按钮的左侧添加“分享”按钮。我希望按钮的样式/颜色与当前的“讨论”按钮相同。
我从https://atmospherejs.com/joshowens/shareit添加了包
我将 {{>shareit}} 添加到 post_item.html 中。
<template name="postItem">
<div class="post">
<a href="#" class="upvote btn btn-default {{upvotedClass}}">$</a>
<div class="post-content">
<h3>{{title}}</h3>
<p>
{{pluralize votes "Vote"}},
by {{author}},
<a href="{{pathFor 'postPage'}}">{{pluralize commentsCount "comment"}}</a>
{{#if ownPost}}<a href="{{pathFor 'postEdit'}}">Edit</a>{{/if}}
</p>
</div>
<a href="{{pathFor 'postPage'}}" class="discuss btn btn-default">Reply</a>
</div>
</template>
这是假设配置它。我是否将其放在 post.item.html 中?如果是这样,怎么做?我只想要推特按钮。
ShareIt.configure({
useFB: true, // boolean (default: true)
// Whether to show the Facebook button
useTwitter: true, // boolean (default: true)
// Whether to show the Twitter button
useGoogle: true, // boolean (default: true)
// Whether to show the Google+ button
classes: "large btn", // string (default: 'large btn')
// The classes that will be placed on the sharing buttons, bootstrap by default.
iconOnly: false, // boolean (default: false)
// Don't put text on the sharing buttons
applyColors: true // boolean (default: true)
// apply classes to inherit each social networks background color
});
这是否在 post_item.js 中启用任何图像卡?我无法弄清楚如何在没有错误的情况下将其放入。
Template.article.helpers({
shareData: function() {
return {
title: this.data,
author: Meteor.users.findOne(this.authorId)
}
});
这里是 post_item.js 文件。
Template.postItem.helpers({
ownPost: function() {
return this.userId == Meteor.userId();
},
upvotedClass: function() {
var userId = Meteor.userId();
if (userId && !_.include(this.upvoters, userId)) {
return 'btn-primary upvotable';
} else {
return 'disabled';
}
}
});
Template.postItem.events({
'click .upvotable': function(e) {
e.preventDefault();
Meteor.call('upvote', this._id);
}
});
【问题讨论】:
标签: javascript html meteor package atmosphere.js