With Ember 2.0 coming down the pipeline and the move away from itemControllers & views, what is the best way to apply the selected class to the currently selected tr element?
Originally there was just the each loop within the controller template that set itemControllers on each tr element. The itemController would then hold the isSelected property as well as hoisting it into the parentController upon select.
Selection currently is working without issues with the bindings of pumpSelected to a property passed into the component.
Although the code is a bit cleaner after the refactor, it's just pushed the need for the itemController lower to me. Any help appreciated.
Component .hbs snippet:
{{#each pump in results}}
<tr {{action 'select' pump}} {{bind-attr class='isSelected:selected'}}>
<td>{{pump.modelNumber}}</td>
</tr>
{{/each}}
Component Definition:
PumpResultComponent = Ember.Component.extend
tagName: 'table'
classNames: ['table', 'table-striped']
actions:
select: (selectedPump)->
@set 'pumpSelected', selectedPump
Aucun commentaire:
Enregistrer un commentaire