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

David Collado

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?

Hubert OG

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

    ...
  };

});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How do I add a class to a given element?

From Dev

How do i add an element to body using angular2

From Dev

How do I add a class to the body using jQuery, scrollTop, and toggleClass

From Dev

How do I add a class to an element and keep it there until the mouse leaves with animate.css?

From Dev

How do i add the class to the input element of adjacent element?

From Dev

How to add a class to an element with CSS

From Dev

How do I add a class on click to a parent element in AngularJS?

From Dev

How do I add a class on click to a parent element in AngularJS?

From Dev

How do I add LinkedIn login to Meteor?

From Dev

How do I add and remove CSS class on keyup in a textarea?

From Dev

how do you modify the actual css of a class rather than add a style to each element of that class?

From Dev

How to add CSS class dynamically to html element

From Dev

How to add | remove css class in angular element?

From Dev

how to only target a css class if it is the first element within the body tag?

From Dev

How to add css class to body tag in layout in yii2?

From Dev

How to add css class to an element inside nav element

From Dev

In Meteor, how do I attach a Template Event to a dynamically inserted element?

From Dev

How can i add a class to the body depending on url

From Dev

Add class to body element based on viewport height

From Dev

Add class to body element based on viewport height

From Dev

How do I add an element to a SSJS array?

From Dev

How do I add attributes to a root element when the class is generated by JAXB?

From Dev

How do I select the previous class element

From Dev

How do I add oplog support to my Meteor app?

From Dev

How do I add a variable to a phonegap plugin with Meteor?

From Dev

How do I add oplog support to my Meteor app?

From Dev

I can't add css class to new element

From Dev

How to add class for body tag

From Dev

How do I add :hover on the nth child of an element using CSS2 selectors?

Related Related

  1. 1

    How do I add a class to a given element?

  2. 2

    How do i add an element to body using angular2

  3. 3

    How do I add a class to the body using jQuery, scrollTop, and toggleClass

  4. 4

    How do I add a class to an element and keep it there until the mouse leaves with animate.css?

  5. 5

    How do i add the class to the input element of adjacent element?

  6. 6

    How to add a class to an element with CSS

  7. 7

    How do I add a class on click to a parent element in AngularJS?

  8. 8

    How do I add a class on click to a parent element in AngularJS?

  9. 9

    How do I add LinkedIn login to Meteor?

  10. 10

    How do I add and remove CSS class on keyup in a textarea?

  11. 11

    how do you modify the actual css of a class rather than add a style to each element of that class?

  12. 12

    How to add CSS class dynamically to html element

  13. 13

    How to add | remove css class in angular element?

  14. 14

    how to only target a css class if it is the first element within the body tag?

  15. 15

    How to add css class to body tag in layout in yii2?

  16. 16

    How to add css class to an element inside nav element

  17. 17

    In Meteor, how do I attach a Template Event to a dynamically inserted element?

  18. 18

    How can i add a class to the body depending on url

  19. 19

    Add class to body element based on viewport height

  20. 20

    Add class to body element based on viewport height

  21. 21

    How do I add an element to a SSJS array?

  22. 22

    How do I add attributes to a root element when the class is generated by JAXB?

  23. 23

    How do I select the previous class element

  24. 24

    How do I add oplog support to my Meteor app?

  25. 25

    How do I add a variable to a phonegap plugin with Meteor?

  26. 26

    How do I add oplog support to my Meteor app?

  27. 27

    I can't add css class to new element

  28. 28

    How to add class for body tag

  29. 29

    How do I add :hover on the nth child of an element using CSS2 selectors?

HotTag

Archive