I'm currently using the Ember input helpers to render data bound form controls:
{{input class="form-control" type="email" value=email }}
This generates the following HTML:
<input id="ember502" class="ember-view ember-text-field form-control" type="email" value="[email protected]">
HTML 5 input controls support the required attribute on elements. This attribute has no value. Attempting to pass the value into the template causes a compilation error and using something like required=true
will not function correctly since the attribute is not empty.
How can I modify the ember TextInput view to include attributes without values? I've attempted to subclass it but the API is preventing direct access.
By default ember doesn't map all options passed to input view helper like html attributes. You can achieve this using attributeBindings
.
Ember.TextSupport.reopen({
attributeBindings: ['required']
});
Give a look in that fiddle to see this in action http://jsfiddle.net/marciojunior/hRx5E/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With