Here is my dilemma. I'm currently loading my categories using a static variable onto the 'category' page. Everything loads and the links are clickable but when a user clicks on the category. The 'categoryPage' won't load the respective images that belong to that category. Here is my code.
categoryPage HTML:
<template name="categoryPage">
<div class="text-center light-container" id="home-section">
<h1>{{categoryName}}</h1>
<hr/>
<div class="row">
{{#each categoryGifs}}
<a href="{{pathFor 'gif'}}">
<img class="freezeframe gifs" data-id="{{_id}}" src="{{image}}"/>
</a>
{{/each}}
</div>
</div>
</template>
categoryPage JS:
Template.categoryPage.helpers({
// Load 16 most recent ones
// When down arrow is click load another 16 more gifs
'categoryName': function(){
var category = this.params.category;
return category;
},
'categoryGifs': function() {
var category = this.params.category;
console.log(category);
return GifsCollection.find({category: category}, {fields: {_id: 1, image: 1, category: 1} });
}
});
Router JS:
Router.route('/categories', {
name: 'categories',
template: 'categories',
fastRender: true
});
Router.route('/categories/:category', {
name: 'categoryPage',
template: 'categoryPage',
data: function(){
var category = this.params.category;
return GifsCollection.find({category: category});
},
fastRender: true
});
in 'categoryGifs': function(), change
with:
here is the working code:
http://meteorpad.com/pad/AdRS8mfyHsZjA2Rvp/Leaderboard