I would like to style my input fields in ember.js like this: http://tympanus.net/codrops/2015/01/08/inspiration-text-input-effects/
我想在ember.js中设置我的输入字段,如下所示:http://tympanus.net/codrops/2015/01/08/inspiration-text-input-effects/
It is not just the input field, but is accompanied also by:
它不仅仅是输入字段,还伴随着:
<span class="input input--haruki">
<input class="input__field input__field--haruki" type="text" id="input-1" />
<label class="input__label input__label--haruki" for="input-1">
<span class="input__label-content input__label-content--haruki">First Name</span>
</label>
</span>
What is a good way to wrap this for a convenient re-use? Do you recommend putting this into an ember component?
为方便重复使用包裹它的好方法是什么?你建议把它放入一个余烬组件吗?
Thank you, Manuel
谢谢你,曼努埃尔
1
A good start might be implementing a component as follows:
一个好的开始可能是实现一个组件如下:
App.CoolTextfieldComponent = Ember.Component.extend({
tagName: 'span',
classNames: ["input", "input--haruki"],
idValue: null,
label: null
});
Component template as follows:
组件模板如下:
<script type="text/x-handlebars" id="components/cool-textfield">
{{ input type="text" id=idValue class="input__field input__field--haruki" value=value}}
<label class="input__label input__label--haruki" {{ bind-attr for=idValue }}>
<span class="input__label-content input__label-content--haruki">{{ label }}</span>
</label>
</script>
This can then be used in your templates as follows:
然后可以在模板中使用它,如下所示:
{{ cool-textfield idValue="input-1" label="First Name" value=name}}
{{cool-textfield idValue =“input-1”label =“First Name”value = name}}
Working example here
这里的工作示例
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2015/03/12/d36f034b3fa7b3a67671401466a2e104.html。