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):

  {{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:

  export default Ember.Component.extend({
    setElementId: Ember.on('init', function() {
      let index = this.get('index');
      this.set('elementId', 'component-id' + index);
    })
  });
doc_EmberJs
2016-11-30 16:54:01
Comments
Leave a Comment

Please login to continue.