I have homepage, contact page, and several other product related pages in my app.
The goal is to apply a background image to ONLY specifc routes: /homepage
and /contact
. If user navigates away from either route, apply some css change.
I am hacking this together now with a helper on my homepage, like so:
Template.homepage.rendered = function () {
var route = Router.current();
if ( route.path == '/' ) {
document.body.className = "showBackgroundImage";
}
};
Partial win here, since this will activate the css, but I need to deactivate when route changes. I have also tried the following within my router.js
:
this.route('homepage', {
path: '/',
onAfterAction: function (argument) {
// add a class name to body
document.body.className = "showBackgroundImage";
}
});
And CSS in the background standard:
.showBackgroundImage {
background: url(bgImage.jpg) no-repeat center center fixed;
}
rendered
anddestroyed
callbacks of said layout, i.e.:Template.layout.rendered = function() {$('body').addClass('layoutBody')};
and thenTemplate.layout.destroyed = function() {$('body').removeClass('layoutBody')};
– Strickle