ViewTargetActionSupport#elementId

elementIdStringpublic

Defined in packages/ember-views/lib/mixins/view_support.js:250

The HTML id of the view's element in the DOM. You can provide this value yourself but it must be unique (just as in HTML):

1
{{my-component elementId="a-really-cool-id"}}

If not manually set a default value will be provided by the framework.

Once rendered an element's elementId is considered immutable and you should never change it. If you need to compute a dynamic value for the elementId, you should do this when the component or element is being instantiated:

1
2
3
4
5
6
export default Ember.Component.extend({
  setElementId: Ember.on('init', function() {
    let index = this.get('index');
    this.set('elementId', 'component-id' + index);
  })
});
doc_EmberJs
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.