Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Add CSS Class to body Element in Meteor?

Tags:

html

css

meteor

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?

like image 559
David Collado Avatar asked Jun 24 '14 09:06

David Collado


1 Answers

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');
    },

    ...
  };

});
like image 120
Hubert OG Avatar answered Oct 30 '22 19:10

Hubert OG