dimanche 28 décembre 2014

Ember class attributes for falseys are not being assigned when rendering page

Ember class attributes for falseys are not being assigned when rendering page. I have two button elements Yes / No. The inactive button has a class rendering the opacity : .3 That is working fine. However I need to set a default behavior on these buttons so that on rendering the page the Yes is inactive. Should be simple I just set the property accordingly. However it isn't adding the appropriate class for the false value.


Hope it is clear what I am trying to do and what the problem is. Thank you for your time.


I made a JSbin http://jsbin.com/vixayatuda/1/edit?html,css,js,output



window.App = Ember.Application.create();

App.ApplicationController = Em.Controller.extend({
takingTrade: false,

actions: {
makeTrade: function() {
this.set('takingTrade', true);
},
makeNotTrade: function() {
this.set('takingTrade', false);
}

}
});


<script type="text/x-handlebars">
<button {{action 'makeTrade' this}} class="btn btn-success" {{bind-attr class="takingTrade::inactive"}}>YES</button>
<button {{action 'makeNotTrade'}} class="btn btn-success" {{bind-attr class="takingTrade:inactive"}}>NO</button>
<p>{{takingTrade}}</p>
</script>




Aucun commentaire:

Enregistrer un commentaire