Reputation: 4223
I have two list of models which have relations.
A has many B
I loop through B
with {{#each}}
and generate a <table>
with it and every row has a <select>
where all A
s, that exist, are listed.
If an B
belongs to an A
it should be selected in the <select>
Example:
<table>
{{#each b in listofb}}
<tr><td>
<select>
{{#each a in listofa}}
{{#if b belongsto a}}
<option selected>a.someAttribute</option>
{{else}}
<option>a.someAttribute</option>
{{/if}}
{{/each}}
</select>
</td></tr>
{{/each}}
</table>
There is probably a way to do this with handlebar-helpers, but I don't know if I can use their output later with Ember controller actions.
Upvotes: 0
Views: 237
Reputation: 14943
Use Ember.Select
http://emberjs.com/api/classes/Ember.Select.html
{{view 'select' value=someControllerProperty}}
It helps you keep logic inside the controller.
Now, in the controller you can react upon changes to the value selected with:
processValueChange: function() {
// do stuff
}.property('someControllerProperty')
Upvotes: 1