Alexander Taylor
Alexander Taylor

Reputation: 17642

Ember: bind-attr boolean behavior in input helpers

According to Ember's website:

If you use {{bind-attr}} with a Boolean value, it will add or remove the specified attribute. For example, given this template:

Let's say I have some property isReadOnly on a controller. This works nicely:

<input type="text" {{bind-attr disabled=isReadOnly}}> //disabled only when isReadOnly is true

But input helpers don't have this behavior for boolean values, which is inconvenient for the disabled attribute:

{{input type="text" disabled=isReadOnly}} //disabled when isReadOnly is not null

I'd like to be able to set isReadOnly to false and have the box disabled. How to combine this ability with benefits of input helpers?

Thanks (:

Upvotes: 0

Views: 318

Answers (1)

undeletable
undeletable

Reputation: 1580

Try {{input type="text" disabledBinding="isReadOnly"}}

Upvotes: 0

Related Questions