Yeah you have two ways:
Logic in Controller. You can subscribe with an array to multiple collections. This would be the way you go when you show all the comments instantly.
this.route('book', {
path: '/book/:_id',
template: 'bookView',
/* just subscribe to the book you really need, change your publications */
waitOn: function() {
return [Meteor.subscribe('book', this.params._id),
Meteor.subscribe('comments', this.params._id)];
},
data: function() {
return {
book : Books.findOne(this.params._id),
comments: Comments.find(this.params._id)}
}
});
If you dont want to show comments until they are requested by the user. You can follow another way:
You can set the bookId
on buttonclick
into a Session variable. Than you can define a Deps.autorun function which subscribes to the comments collection with the bookId
provided in your Session variable. In your comments template you just have to do the normal collection request. If you need more hints about this way let me know.