javascript - How to Change body background for different pages in ember -
i developing ember app , have white background signup page , login page , rest of pages should have grey background.
at moment changing colours of body tag in controller (application.js file)
import ember 'ember'; export default ember.controller.extend({ isverified:false, bgcolour: function(){ if(['users.login','users.signup'].indexof(this.get('currentpath')) != -1){ return 'white'; } else{ return 'bg-grey'; } }.property('currentpath'), });
any advices how make better/cleaner way?
we have deal lot of arbitrary requests our clients easiest way target specific page, add route name body
.
ember.route.reopen({ activate: function() { var cssclass = this.tocssclass(); // don't need application class // added body if (cssclass != 'application') { ember.$('body').addclass(cssclass); } }, deactivate: function() { ember.$('body').removeclass(this.tocssclass()); }, tocssclass: function() { return this.routename.replace(/\./g, '-').dasherize(); } });
that said it's big dirty, create thememixin
, set on routes. it's simpler version of this: https://github.com/ronco/ember-cli-meta-tags
Comments
Post a Comment