Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.js Is there a way to create a custom #ID .class name instead of default ember?

Tags:

ember.js

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>
like image 687
Upworks Avatar asked Dec 07 '22 14:12

Upworks


1 Answers

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...

like image 149
thierry Avatar answered Jan 11 '23 23:01

thierry