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.

<button disabled={{if itemSelected true null}}>a button<button>

Solution 2:

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

// ../helpers/boolean-disabled.js

import Ember from 'ember';

export function booleanDisabled(params/*, hash*/) {
  var disabled = params[0];
  if(disabled) {
    return 'disabled';
  } else {
    return null;
  }
}

export default Ember.HTMLBars.makeBoundHelper(booleanDisabled);

Then in the template

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

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