typeahead.js: problem with source async
$('#input-rms').typeahead({
hint: true,
highlight: true,
minLength: 2,
classNames: {
menu: 'tt-dropdown-menu'
}
},
{
name: 'rms',
limit: 10,
source: function (q, sync, async) {
$.ajax('/api/getrms?name='+q, // it will return a list of data of length 7
{
success: function(data, status){ async(data); }
}
);
}
});
Problem: The ajax url will return a list of data of length 7, however, the suggestions only render the first 3 results.
Can anyone gives a example about how to use the async in source.
About this issue
- Original URL
- State: open
- Created 9 years ago
- Comments: 16 (3 by maintainers)
Struggled with this problem for a long time today. Moving the line seems to fix it. How come it isn’t being fixed in the release?
+1 for pushing this fix. I also spent over an hour digging into the source of 0.11.1 and came to the same conclusion that the “rendered +=” line needs to be moved down.