jeudi 2 novembre 2017

Not able to add the `class` name on the `body` tag by `route` in ember engine

I require to add the class name for each and every pages to write the page specific css properties. for that I try the following: but nothing works. I am not get any errors too..

any one please help me here?

my code :

import buildRoutes from 'ember-engines/routes';
import Ember from 'ember';


export default buildRoutes(function () {

  this.route('dac', {path: '/dac'}, function () {
    this.route('icp');
    this.route('dac-product-selection');
  });
  this.route('cs2i', {path: '/cs2i'}, function () {
    this.route('cs2i-product-selection');
    this.route('balance', {path: '/balance'}, function () {
      this.route('balance-details');
      this.route('balance-edit');
      this.route('balance-review');
      this.route('balance-confirmation');
    });
    this.route('purchase', {path: '/purchase'}, function () {
      this.route('purchase-details');
      this.route('purchase-edit');
      this.route('purchase-review');
      this.route('purchase-confirmation');
    }); 

  });

  //adding class name to body but not works!!

  Ember.Route.reopen({
    activate: function() {
    var cssClass = this.toCssClass();
    if (cssClass != 'application') {
      Ember.$('body').addClass(cssClass);
    }
  },
  deactivate: function() {
    Ember.$('body').removeClass(this.toCssClass());
  },
    toCssClass: function() {
      return this.routeName.replace(/\./g, '-').dasherize();
    }
  });


});




Aucun commentaire:

Enregistrer un commentaire