I am working on some project, i want to return filtered data to some new page, what i am facing right now is, that output is shown on same template, so lot of extra stuff occurs which i do not want. I want to redirect it using router, but this filter function is a part of images_thumbnail.
Client > main.html
<template name="images_thumbnail">
//lot of stuff + images
{{#each images}} //show all images from public folder
<img src=""some_image.jpg" alt="img_title" />
<caption>
<a href="#" class="js-set-genre-filter">
{{img_genre}} //image_genre associated with this image
</a>
</caption>
{{/each}}
</template>
When I click image genre (say Thriller, Comedy, etc.), image filter is set
Client > main.js
Router.route('/images', function(){
this.render('navigation_bar',{
to: 'header'
});
this.render('owl_carousel', {
to: 'carousel'
});
//images_thumbnail template along with navbar, carousel
this.render('images_thumbnail', {
to: 'body'
});
});
Tempalte.images_thumbanil.events({
'click .js-set-genre-filter':function(event){
Session.set("genreFilter", this.img_genre);
console.log(this.img_genre); //gives Comedy/Thriller
}
})
Template.images_thumbnail.helpers({
images:function(){
if(Session.get("genreFilter"))
return Images.find({img_genre: Session.get("genreFilter")};
//This is the output, but i want to redirect it to some
//new template, instead of images_thumbnail template
}
})
When no filter is set Output when no Filter is set, Navigation bar, Carousel, rest stuff is visible
Filter output, when genreFilter is set Navigation bar, button, Headings are shown which are not needed for this content
I don't think I understand fully what you want, if you want to redirect your route to another at the point of your code, simply use Router.go('/newPath')
In addition, Iron router was great package still, but Meteor Developer Group(MDG) and a lot of people changed to use FlowRouter because of maintanence and to focus on routing itself. (Iron Router controls pub/sub and lifecycle too much.)
So consider to FlowRouter too-