4

Is there a way to pass in a custom class or id namespace instead of the default ember?

example: turn this

    <body class="ember-application">
    <div class="ember-view"></div>
    </body>

into:

    <body class="myapp-application">
    <div class="myapp-view"></div>
    </body>
Upworks
  • 267
  • 2
  • 15

2 Answers2

12

You can pass in a custom id, instead of the default "ember-[numview]".

Just set the elementId field of the Ember.View Class

var mainView = Ember.View.create({
  tagName: "section",
  elementId: "main"
})

will generate:

<section id="main" class="ember-view">
</section>

To remove/modify the default className "ember-view", you need find and edit the classNames field on the PrototypeMixin on the View class...

Em.View.PrototypeMixin.mixins[2].properties.classNames = []

var mainView = Ember.View.create({
  tagName: "section",
  elementId: "main"
})

will generate:

<section id="main">
</section>

No idea about the side effects...

matthias krull
  • 4,389
  • 3
  • 34
  • 54
thierry
  • 121
  • 1
  • 3
3

No.

"ember-application" is hardcoded in Ember.EventDispatcher#setup, and "ember-view" is similarly a static string in the classNames property on Ember.View. Because 'classNames' is a concatenated property (which means subclasses combine their values, instead of replace them), you can add 'myapp-view' to the classNames array, but you can't remove (easily) values from super classes.

Christopher Swasey
  • 10,392
  • 1
  • 31
  • 25