Skip to content Skip to sidebar Skip to footer

Ember + Htmlbars: "boolean" Bound Attributes Are Not Booleans

I'm migrating an Ember 1.5 Handlebars app to current stable Ember and HTMLBars and it seems that a bound controller property must return 'disabled' or null to work as expected with

Solution 1:

I just ran into the same thing, and I found a shorter solution that works for me.

<buttondisabled={{ifitemSelectedtruenull}}>a button<button>

Solution 2:

I came up with a reasonable solution for this by using a bound helper.

// ../helpers/boolean-disabled.jsimportEmberfrom'ember';

exportfunctionbooleanDisabled(params/*, hash*/) {
  var disabled = params[0];
  if(disabled) {
    return'disabled';
  } else {
    returnnull;
  }
}

exportdefaultEmber.HTMLBars.makeBoundHelper(booleanDisabled);

Then in the template

<buttondisabled="{{boolean-disabled itemSelected}}">

Post a Comment for "Ember + Htmlbars: "boolean" Bound Attributes Are Not Booleans"