lundi 23 novembre 2015

Disable button if certain number of checkbox are checked

i have a template each have some checkboxes:

<input class="general" type="checkbox"/>
<input class="about" type="checkbox"/>
<input class="money" type="checkbox"/>

And i have this button too:

<button class="disable" {{action "filter"}}>Filter</button>

In the controller of this template, i'm trying to remove the class disable if one or more checkbox are clicked, but more than that, i need to know each checkbox are clicked.

I'm relative new in the Ember word... and i really try to make it work, but i don't understand very much to do so.. I was trying like this:

OBS: I was trying to enable the button.


export default Ember.Controller.extend({
  checkbox: 0,

  allowFilter: Ember.computed('checkbox', function() {
    let result = false;

    this.get('checkbox') ? result = true : result = false;
    return result;
  }),

  actions: {
    checkboxClicked () {
      this.get('checkbox') =+ 1;
    },

    filter () {

    }
  }
});

And in the button:

<button class="{{if allowFilter "" "disable"}}" {{action "filter"}}>Filter</button>

But.. well.. didn't worked..




Aucun commentaire:

Enregistrer un commentaire