0

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?

3
  • Or you can extend textarea and use a custom attribute which will be observed and readonly can be applied through jquery based on the custom attribute.
    – acid_srvnn
    Sep 12, 2015 at 15:37
  • disabled should work fine for you. Only readonly causes readonly just by presence.
    – acid_srvnn
    Sep 12, 2015 at 15:42
  • Can you provide the jQuery syntax for doing this?
    – Lazloman
    Sep 12, 2015 at 17:09

1 Answer 1

1

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

5
  • {{textarea disabled=disabled value=value}} doesn't work??
    – acid_srvnn
    Sep 12, 2015 at 18:35
  • @AcidBurn personally, I didn't have any problems with disabled. I just posted an example how such problem can be solved. I think I should edit my answer and change disabled to readonly to prevent confusion. Sep 12, 2015 at 22:20
  • The disabled attribute, like the readonly attribute does not require a value to work. Its presence alone is enough to disable the element. When used in an Ember input helper, a value has to be supplied, otherwise you'll get a build error, but the value itself is superfluous.
    – Lazloman
    Sep 13, 2015 at 5:04
  • Ah ok. The docs also say so. But there seems to some confusion about this. For me disabled=disabled works fine. Ty for the info.
    – acid_srvnn
    Sep 13, 2015 at 5:45
  • Ah yes, disabled=disabled does toggle the disabled attribute. I stand corrected.
    – Lazloman
    Sep 13, 2015 at 23:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.