Reputation: 413
The textarea html tag has an attribute named readonly
, which doesn't work in the Ember {{textarea}}
helper. <textarea readonly></textarea>
works, and {{testarea readonly}}
generates an error. Any easy way to make the textarea read only while using {{textarea}}
?
Upvotes: 1
Views: 2723
Reputation: 2592
The issue is because you were only specifying readonly
and not setting readonly
to a truthy value
the way to force a textfield to be readonly
<script type="text/x-handlebars" data-template-name="app">
{{textarea readonly=true}}
</script>
Upvotes: 2
Reputation: 3648
This is a quote from the EmberJS documentation for input helpers:
Using these helpers, you can create these views with declarations almost identical to how you'd create a traditional
<input>
or<textarea>
element.
Both of these will work
{{textarea readonly="readonly"}}
{{textarea readonly="true"}}
Upvotes: 4
Reputation: 7919
You can extend the textarea
view and add readonly property to it:
App.TextAreaRView = Ember.TextArea.extend({
attributeBindings:['readonly'],
readonly:true
});
Ember.Handlebars.helper('textarea-R', App.TextAreaRView);
and in handlebars you can use this:
<script type="text/x-handlebars" data-template-name="app">
{{textarea-R}}
</script>
Upvotes: 1