corejavascript / corejavascript/typeahead.js
Remote is always used
- Dominant language
- JavaScript
- Stars
- 968
- Forks
- 231
- PR merge metrics
- No merged PRs in 30d
Description
I understand that remote should be used only when the prefetch results do not exceed the limit set.
I've set the limit to 1 and prefetch has more than one entry. Still it uses remote to fetch data and ultimately shows 1 result only.
```
initialise_quick_search: function () {
var building_data = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('building_name'),
queryTokenizer: Bloodhound.tokenizers.nonword,
prefetch: {
url: '/quick_search/quick_search_results?search_buildings=1',
//cache: false
},
remote: {
url: '/quick_search/quick_search_results?search_buildings=1&query=%QUERY',
wildcard: '%QUERY',
cache: false
}
});
building_data.initialize();
var $quick_search = $('#quick_search');
$quick_search.typeahead({
highlight: true,
hint: false,
minLength: 2,
},
{
name: 'buildings',
display: 'building_name',
source: building_data,
limit: 1,
templates: {
header: 'Buildings',
suggestion: function (data) {
return '
}
}
}
);
$quick_search.bind('typeahead:close', function (ev, suggestion) {
$quick_search.val('');
$quick_search.typeahead('close');
});
$quick_search.bind('typeahead:select', function (ev, suggestion) {
window.open(suggestion.href, '_blank');
});
}
```
Contributor guide
Assessment
This issue has not been assessed yet.