[英]How to add an input-group-addon ( Bootstrap CSS ) onto an Alpaca.js field
Hoping for some assistance , I require an appended and prepended Input group addon As shown here on bootstrap.com into a alpaca.js form. 希望获得一些帮助,我需要一个附加和前置的Input组插件, 如bootstrap.com上所示,它是alpaca.js形式。
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css" rel="stylesheet"/> <div class="input-group"><span class="input-group-addon">$</span> <input type="text" class="form-control" placeholder="Recipient's username" aria-describedby="basic-addon2"> <span class="input-group-addon" id="basic-addon2">@example.com</span> </div>
The template (handlebars) should look like the snippet below, however documentation on the site does not cover custom options and template editing like this. 模板(把手)应类似于下面的代码片段,但是站点上的文档并未涵盖自定义选项和模板编辑。
<script type="text/x-handlebars-template"> {{#if options.component}} <div class="input-group"> {{#if options.prepend}} <span class="input-group-addon" id="basic-addon-prepend">{{options.prepend}}</span> {{/if}} {{/if}} <input type="{{inputType}}" id="{{id}}" {{#if options.placeholder}}placeholder="{{options.placeholder}}"{{/if}} {{#if options.size}}size="{{options.size}}"{{/if}} {{#if options.readonly}}readonly="readonly"{{/if}} {{#if name}}name="{{name}}"{{/if}} {{#each options.data}}data-{{@key}}="{{this}}"{{/each}} {{#each options.attributes}}{{@key}}="{{this}}"{{/each}}/> {{#if options.component}} {{#if options.append}} <span class="input-group-addon" id="basic-addon-append">{{options.append}}</span> {{/if}} </div> {{/if}} </script>
The question would be : Where should this code be changed ,and how should the modified template be executed ? 问题是:应该在哪里更改此代码,以及如何执行修改后的模板?
Thanks in advance! 提前致谢!
If you're tring to use a custom template for a field you should set it into view object like this : 如果您打算对字段使用自定义模板,则应将其设置为如下所示的view对象:
"view": {
"fields": {
"/username": {
"templates": {
"control-text": "#input-group-addon-template"
}
}
}
}
Here's a working fiddle for this. 这是一个工作的小提琴 。 If this isn't what you're looking for please fill me with more details and I'll be glad to help :) 如果这不是您想要的,请向我提供更多详细信息,我们将很乐意为您提供帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.