mardi 21 juin 2016

Ember - get state of multiple checkboxes one by one

I am working on an Ember app (version 1.11, old one) and have multiple checkboxes build over in loop, code as below. I need to know if an element has been checked or unchecked in action.

Ember ehbs:


 <label>
 <input type="checkbox" checked="isChecked" />
 <span></span>
 </label>


Ember Component:

var component = Ember.Component.extend({
 isChecked: true,
 actions: {
  getData: function(data){
   var state = this.get('isChecked');
   var type = data.type;
  }
 }
})

I thought the variable's "isChecked" value will be maintained for each individual checkbox, but its not the case, it is just one variable for all checkboxes. So, how can I achieve this OR check individual states for all checkboxes whether its checked or unchecked.

In long run, I am trying to get here - http://ift.tt/28LhU85,output but dont want to access and play with DOM as its done here.




Aucun commentaire:

Enregistrer un commentaire