问题描述:

I have page design, which needs to be displayed into div element with class displayInline:

displayInline: { display: inline-block; }

(there are some makeup designers with hands derived from ...).

Before Ember.js 1.13.x I use hint from Ember.js documentation:

app.ApplicationView = Ember.View.extend({

classNames: ['displayInline']

});

Which correctly produces what I want:

<div id="ember493" class="ember-view displayInline">...</div>

This worked for me now, but generates deprecation and may not work in next Ember.js releases:

DEPRECATION: Ember.View is deprecated. Consult the Deprecations Guide for a migration strategy. See http://emberjs.com/deprecations/v1.x/#toc_ember-view for more details.

How to add custom css class for Application?

I tried searching in Docs and Web, but found no results.

网友答案:

PedroCheckos' answer will work if you're willing to add another element to the DOM. But if you don't want to do that (which I didn't), then that solution doesn't really work well. Unfortunately, the Ember team hasn't provided a solution for this yet. If you look at the view deprecation guide, it suggests workarounds that don't really apply. Until routable components land (likely in 2.1 or 2.2), you're stuck with extending the view as you're doing now.

However, the Ember team has provided an addon that will eliminate the deprecation notice. I suggest using that addon until routable components land, then swapping out your view/controller for a component.

网友答案:

I am found two ways and it's worked in Ember version > 1.13

  1. Use solution from Issue#11906, e.g. change:
app.ApplicationView = Ember.View.extend({
    classNames: ['displayInline']
});

to:

app.ApplicationView = Ember.Component.extend({
    classNames: ['displayInline']
});
  1. Make right css selector:
body > div.ember-view {
    display: inline;
}
相关阅读:
Top