Typeahead afterselect 填充到另一个输入文本
Typeahead afterselect fill to another input text
我想为另一个输入文本填充一些值。怎么做?
<script>
var projects = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.idSales); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '<?php echo BASE_URL() ?>Sales/getSalesAll?query=%QUERY',
wildcard: '%QUERY'
}
});
$('#listSales').typeahead({
hint: true,
highlight: true,
minLength: 0
},
{
name: 'projects',
display: function(item){ return item.idSales+' – '+item.namaSales},
source: projects.ttAdapter(),
templates: {
empty: [
].join('\n'),
suggestion: Handlebars.compile('<p>{{namaSales}} - {{email}}</strong> </p>')
}
});
</script>
这是 html 代码:
<div class="search-form wd-lg-100p">
<input id="listSales" name="idSales" type="search" class="form-control" placeholder="Enter sales name" required>
<input id="emailSales" name="emailSales" class="form-control" value="" disabled>
</div>
因此,在输入 select 预先输入的值 #listSales
之后,电子邮件值会自动填充 #emailSales
。
怎么做?谢谢
问题已解决。我正在为我的案例使用 typeahead:select。谢谢
我想为另一个输入文本填充一些值。怎么做?
<script>
var projects = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.idSales); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '<?php echo BASE_URL() ?>Sales/getSalesAll?query=%QUERY',
wildcard: '%QUERY'
}
});
$('#listSales').typeahead({
hint: true,
highlight: true,
minLength: 0
},
{
name: 'projects',
display: function(item){ return item.idSales+' – '+item.namaSales},
source: projects.ttAdapter(),
templates: {
empty: [
].join('\n'),
suggestion: Handlebars.compile('<p>{{namaSales}} - {{email}}</strong> </p>')
}
});
</script>
这是 html 代码:
<div class="search-form wd-lg-100p">
<input id="listSales" name="idSales" type="search" class="form-control" placeholder="Enter sales name" required>
<input id="emailSales" name="emailSales" class="form-control" value="" disabled>
</div>
因此,在输入 select 预先输入的值 #listSales
之后,电子邮件值会自动填充 #emailSales
。
怎么做?谢谢
问题已解决。我正在为我的案例使用 typeahead:select。谢谢