Lazloman
Lazloman

Reputation: 1347

Binding readonly value in EmberJS

I need to bind a text area's readonly property to a property in my EmberJS component, but the readonly property (as well as the disabled property), don't take values; their presence alone gives their behavior. From this discussion: GitHub discussion

This appears to be a regression, as per the discussion, before 1.13.3, the readonly property was bindable. Now, the presence of the attribute in an EmberJS, {{textarea readonly=false}}, with or without a value yields a read-only text area. Has anyone else run into this? Any work arounds?

Upvotes: 0

Views: 843

Answers (1)

Gennady Dogaev
Gennady Dogaev

Reputation: 5991

I didn't run into this issue with ember 1.13.9. Maybe because I don't use textare or maybe because I use ember-cli-materialize for UI. I see a workaround in creating own component, that will wrap textarea in if block. Something like

//app/templates/components/my-textarea.hbs
{{#if readonly}}
  {{textarea readonly="readonly" value=value}}
{{else}}
  {{textarea value=value}}
{{/if}}

Not ideal solution, but should work

Upvotes: 1

Related Questions