我一直在尝试组合多个功能in typeahead plugin特别是多个数据集+空白+默认建议。至今没有运气,希望有人能够帮助多个Typeahead数据集的单个空白和建议模板
眼下,使其工作,这是多重数据集--- OR ---之间进行选择空+默认建议
我的HTML
<div class="form-group has-feedback" id="citydiv">
<label class="col-sm-4 control-label" for="city">City/Provinces<span style="color:red">*</span></label>
<div class="col-sm-4" id="multiple-datasets">
<input id="cities" name="cities" class="typeahead form-control" type="text">
<span class="glyphicon glyphicon-search form-control-feedback"></span>
</div>
</div>
我的JavaScript
var city1 = ['a','b','c','d'];
var city2 = ['e','f','g','h'];
var city3 = ['i','j','k','l'];
var city4 = ['m','n','o','p'];
$('#multiple-datasets .typeahead').typeahead({
highlight: true,
hint: true,
minLength: 1,
},
{
source: substringMatcher(city1),
templates: {
header: '<h4>city1</h4>'
}
},
{
source: substringMatcher(city2),
templates: {
header: '<h4>city2</h4>'
}
},
{
source: substringMatcher(city3),
templates: {
header: '<h4>city3</h4>'
}
},
{
source: substringMatcher(city4),
templates: {
header: '<h4>city4</h4>'
}
});
在GitHub上有一个问题:https://github.com/twitter/typeahead.js/issues/780 –