ember.js - How to set the class of the root div in an Ember application? -


i have ember 2.3.0 application. when application initialized, ember creates root div inside which, create inserted. div looks this:

<div id="ember351" class="ember-view"></div> 

this element first child of <body> element. need able set class of div.

how do that?

maybe don't need class inside div, can access div css or javascript.

you can access div via css this

body > .ember-view 

or via javascript this

document.queryselector('body > .ember-view') 

update in ember this.

use init hook in application controller in combination ember.run.next function.

// application/controller.js import ember 'ember'; const {   controller,   run { next } } = ember;  export defaultcontroller.extend({     addclass() => {     next(this, function() {       document.queryselector('body > .ember-view').classname += " your-class";     })   }.on('init') }); 

here demo in ember twiddle.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -