Twitter Typeahead only shows only 5 results
Posted
by
user3685388
on Stack Overflow
See other posts from Stack Overflow
or by user3685388
Published on 2014-05-28T21:23:10Z
Indexed on
2014/05/28
21:25 UTC
Read the original article
Hit count: 401
typeahead
I'm using the Twitter Typeahead version 0.10.2 autocomplete but I'm only receiving 5 results from my JSON result set. I can have 20 or more results but only 5 are shown.
What am I doing wrong?
var engine = new Bloodhound({
name: "blackboard-names",
prefetch: { url: "../CFC/Login.cfc?method=Search&returnformat=json&term=%QUERY",
ajax: { contentType: "json",
cache: false }
},
remote: { url: "../CFC/Login.cfc?method=Search&returnformat=json&term=%QUERY",
ajax: { contentType: "json",
cache: false },
},
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace
});
var promise = engine.initialize();
promise
.done(function() { console.log("done"); })
.fail(function() { console.log("fail"); });
$("#Impersonate").typeahead({
minLength: 2,
highlight: true},
{
name: "blackboard-names",
displayKey: 'value',
source: engine.ttAdapter()
}).bind("typeahead:selected", function(obj, datum, name) {
console.log(obj, datum, name);
alert(datum.id);
});
Data:
[ { "id": "1", "value": "Adams, Abigail", "tokens": [ "Adams", "A", "Ad", "Ada", "Abigail", "A", "Ab", "Abi" ] }, { "id": "2", "value": "Adams, Alan", "tokens": [ "Adams", "A", "Ad", "Ada", "Alan", "A", "Al", "Ala" ] }, { "id": "3", "value": "Adams, Alison", "tokens": [ "Adams", "A", "Ad", "Ada", "Alison", "A", "Al", "Ali" ] }, { "id": "4", "value": "Adams, Amber", "tokens": [ "Adams", "A", "Ad", "Ada", "Amber", "A", "Am", "Amb" ] }, { "id": "5", "value": "Adams, Amelia", "tokens": [ "Adams", "A", "Ad", "Ada", "Amelia", "A", "Am", "Ame" ] }, { "id": "6", "value": "Adams, Arik", "tokens": [ "Adams", "A", "Ad", "Ada", "Arik", "A", "Ar", "Ari" ] }, { "id": "7", "value": "Adams, Ashele", "tokens": [ "Adams", "A", "Ad", "Ada", "Ashele", "A", "As", "Ash" ] }, { "id": "8", "value": "Adams, Brady", "tokens": [ "Adams", "A", "Ad", "Ada", "Brady", "B", "Br", "Bra" ] }, { "id": "9", "value": "Adams, Brandon", "tokens": [ "Adams", "A", "Ad", "Ada", "Brandon", "B", "Br", "Bra" ] } ]
© Stack Overflow or respective owner