How can I add a class in ember js

sparxIT Solutions
    <script type="text/x-handlebars">
        <div class="wrapper">

        <div class="sideMenu">

        {{#link-to 'home'}}Home{{/link-to}}
        {{#link-to 'posts'}}Posts{{/link-to}}
        </div>


        <div class="content">

        {{outlet}}
         </div>

        </div>

    </script>

I am new to ember js. How can I add a class on 'content' class each time when view changes.

Asgaroth

We do something like this:

Ember.Route.reopen({
  activate: function() {
    var cssClass = this.toCssClass();
    // you probably don't need the application class
    // to be added to the body
    if (cssClass !== 'application') {
      Ember.$('body').addClass(cssClass);
    }
  },
  deactivate: function() {
    Ember.$('body').removeClass(this.toCssClass());
  },
  toCssClass: function() {
    return this.routeName.replace(/\./g, '-').dasherize();
  }
});

It would add a class to the body (in your case just use content), that is the same as the current route.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I add a class to the "action" item in Ember?

From Dev

How can I get the name of an Ember Class?

From Dev

How can I add default values for ember has many relationship?

From Dev

How can I unit test class methods in Ember-Cli

From Dev

How can I test a class function with Ember qUnit?

From Dev

How to add Css Class to item inside Ember's {{#each}} loop, according to index? - Ember.js

From Dev

How can I repeat a resource in Ember.js

From Dev

How can I safely share Rails configuration with Ember.js?

From Dev

How can I perform unit test in ember.js ?

From Dev

How can i get tornado error response in ember js action?

From Dev

Ember.js - How can I use a service in another service?

From Dev

How can I safely share Rails configuration with Ember.js?

From Dev

Ember js how can i run a function after model change?

From Dev

How can I use jStorage (or other external JS libs) with Ember.js via Ember-CLI

From Dev

How can I dynamically add a method to a class?

From Dev

How can I add PHP wordwrap to this class?

From Dev

How can I add class to the specific datepicker?

From Dev

How can I not add a class to a specific block?

From Dev

How can I do an Ember.js computed property on an Ember Data model based on an async relationship?

From Dev

How can I do an Ember.js computed property on an Ember Data model based on an async relationship?

From Dev

ember.js + ember-simple-auth how can I load application models after authentication?

From Dev

How can i add numbers to a variable in JS?

From Dev

How can i add numbers to a variable in JS?

From Dev

How can I add sourcemap in Keystone js

From Dev

How can I add a delay to a JS redirect

From Dev

Can i add class to a different element of hover with jquery/js

From Dev

How to add active class only for exact routes and not parent routes in ember js?

From Dev

How do I add an active class to a list of items when an item is clicked on in Ember?

From Dev

How to add a custom environment for Ember js?

Related Related

  1. 1

    How can I add a class to the "action" item in Ember?

  2. 2

    How can I get the name of an Ember Class?

  3. 3

    How can I add default values for ember has many relationship?

  4. 4

    How can I unit test class methods in Ember-Cli

  5. 5

    How can I test a class function with Ember qUnit?

  6. 6

    How to add Css Class to item inside Ember's {{#each}} loop, according to index? - Ember.js

  7. 7

    How can I repeat a resource in Ember.js

  8. 8

    How can I safely share Rails configuration with Ember.js?

  9. 9

    How can I perform unit test in ember.js ?

  10. 10

    How can i get tornado error response in ember js action?

  11. 11

    Ember.js - How can I use a service in another service?

  12. 12

    How can I safely share Rails configuration with Ember.js?

  13. 13

    Ember js how can i run a function after model change?

  14. 14

    How can I use jStorage (or other external JS libs) with Ember.js via Ember-CLI

  15. 15

    How can I dynamically add a method to a class?

  16. 16

    How can I add PHP wordwrap to this class?

  17. 17

    How can I add class to the specific datepicker?

  18. 18

    How can I not add a class to a specific block?

  19. 19

    How can I do an Ember.js computed property on an Ember Data model based on an async relationship?

  20. 20

    How can I do an Ember.js computed property on an Ember Data model based on an async relationship?

  21. 21

    ember.js + ember-simple-auth how can I load application models after authentication?

  22. 22

    How can i add numbers to a variable in JS?

  23. 23

    How can i add numbers to a variable in JS?

  24. 24

    How can I add sourcemap in Keystone js

  25. 25

    How can I add a delay to a JS redirect

  26. 26

    Can i add class to a different element of hover with jquery/js

  27. 27

    How to add active class only for exact routes and not parent routes in ember js?

  28. 28

    How do I add an active class to a list of items when an item is clicked on in Ember?

  29. 29

    How to add a custom environment for Ember js?

HotTag

Archive