I tried to combine several functions in the typeahead plugin , in particular several datasets + empty + default sentences. So far no luck, hope someone can help
Right now, to make it work, it's a choice between multiple datasets --- OR --- empty + default sentences
Fiddle here
My 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>
MY 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>'
}
});
source
share