I'm starting a Meteor project and I want to use different body css classes on different pages. If I add a css class to body I get:
Attributes on <body> not supported
The only way I've found is adding the class using JS. Is there a better way to do this?
The standard practice is to set body class in respective path hooks:
Router.map(function() {
this.route('someRoute', {
path: '/someAddress',
onBeforeAction: function() {
$('body').addClass('someRouteBodyClass');
this.next();
},
onStop: function() {
$('body').removeClass('someRouteBodyClass');
},
...
};
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With