I am rendering some model parameters in Ember, which should behave like a checkbox. Therefore the css class of the clicked element should change, to indicate the state (e.g. green when active). Currently all rendered elements change their class when only one was clicked. How can I only change the css class of the element that was really clicked ? I thought the .this will take care of that.
That is my view template:
{{#each model as |attributes|}}
{{#each attributes.identifiers as |identifier| }}
<div class="col-element">
<div class="checkelement {{state}}" {{action "includeToExport" identifier}}>
<p>{{identifier}}</p>
</div>
</div>
{{/each}}
{{/each}}
That the action in the controller:
includeToExport: function(identifier){
var state = this.get('state');
if (state == 'activated'){
this.set('state','');
// and do something with identifier
}
else {
this.set('state', 'activated');
// and do something with identifier
}},
An that the CSS:
.checkelement.activated {background-color:#4CAF50; }
Thanks for your help!