mercredi 20 mai 2015

Boolean property bound to "disabled" DOM attribute broken?

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 "disabled" or "checked" DOM attributes.

<button disabled={{isDisabled}}> 

In Handlebars isDisabled property is a boolean and all is well.

In HTMLBars it seems I need:

Ember.Controller.extend({
  isDisabled: function() {
    if(this.get('itemSelected')){
      return null;
    } else {
      return 'disabled';
    }
  }
});

Is this correct? This presents a problem of course since a boolean property is expected to be, well, a boolean in the rest of the app, so to get this to work as expected I'll need to add an additional computed property to drive the "boolean-ish" DOM attribute with a "string"/null value set.

Has anyone else encountered this, or the related issue with "checked"?

Using: Ember 1.11.3 + HTMLBars ember-cli 0.2.3




Aucun commentaire:

Enregistrer un commentaire