ember.js - Obtaining component elementId in parent template -
i obtain component auto-generated elementid
in parent template, e.g.
<script type="text/x-handlebars" data-template-name="index"> my-component elementid: {{mycomponentelementid}} {{my-component}} </script>
is there simple way without altering parent controller or my-component
?
elementid
being generated during initialization of component. can sure id set after component inserted dom. therefore, can use didinsertelement
action this:
some-example elementid: {{mycomponentelementid}} {{some-example elementidproxy=mycomponentelementid}} didinsertelement: function() { this.set("elementidproxy", this.get("elementid")); }
thus, proxy elementid
via other binding (elementidproxy
in situation). recommend not set id explicitly, must unique within app. ember takes care that, it's not idea reinvent wheel.
Comments
Post a Comment