Hi I am working on a form component that works with the css library materialize. I got it up and running, but some of the things I had to do to get labels to have the right for value didn’t seem right. I figure since I’m only 2 weeks into ember.js I am just writing hacks when there is a solid way to achieve this. I hope this is the right place for me to inquire.
In a nutshell the component with accept an object array and render a form with different fields based on the object. For materialize to work the label needed to point to the ID of the input.
I first tried just parsing all the ember IDs on the inputs into the respective array and just added a id: property for each object in the aray. Then I tried to bind it to it in the each.
{{#each I in inputs}}
{{input type=I.type}}
<label {{bind attr for=I.id}}>I.input</label>
{{/each}}
This came out with some crazy <label data-bind-attr="435">
(not exact)
My guess here is I.id is populated on didInsertElement, but ember tries to parse this value while it is still undefined. There must be someway to tell ember when its parsing that this attribute belongs to the value of the ID of the {{input}} helper before it.
So I ended up fixing it by just using jQuery to insert the label after each input on didInsertElement: now that it works I am trying to refactor into better ember practices. Can anyone enlighten me on what I was missing to bind the for attribute?