samedi 18 février 2017

Ember | set css class of specific element

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:

  
  
    <div class="col-element">
      <div class="checkelement " >
        <p></p>
      </div>
    </div>
  


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!




Aucun commentaire:

Enregistrer un commentaire