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 pilation 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.
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 pilation 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.
Share Improve this question asked Nov 29, 2013 at 21:25 jhappoldtjhappoldt 2,5261 gold badge21 silver badges24 bronze badges2 Answers
Reset to default 9By 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/marciojunior/hRx5E/
In my case using only attributeBindings
did not help. I wanted to add an empty download HTML attribute to an a
tag, but it was skipped. What I had to do was that I needed to set also the download property to an empty string.
In such a case try to use instead of this:
Ember.TextSupport.reopen({
attributeBindings: ['required']
});
this snippet:
Ember.TextSupport.reopen({
attributeBindings: ['required']
required: ''
});
Maybe it will help ;-)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744347776a4569791.html
评论列表(0条)