Bootstrap Typeahead shows only the first letter

I have a little problem for this to work.

The server answers with the correct json request, however typeahead only displays the first letter of my returned result. For example, if I find k, it will display:
to
to
K
k

Could you help me understand why?

Here is my js

$('.user').typeahead({ source : function(typeahead, query) { return $.post('getUser', { query : query }, function(data) { return typeahead.process(data); }); } }); 

and my html

 <input autocomplete="off" type="text" size="16" id="appendedInputButton" class="user" data-provide="typeahead"> 

I am using the following code

https://gist.github.com/1866577

Thanks.

+4
source share
3 answers

If the server responds with an array of objects with the contact attribute, try the following:

 $('.user').typeahead({ source : function(typeahead, query) { return $.post('getUser', { query : query }, function(data) { return typeahead.process(JSON.parse(data)); }); }, property : 'contact' }); 
+4
source

I had the same problem today, I found that I need to be sure and do

 data-source="['THING1','THINGS2']" 

Make double quotes first , then single quotes inside . At first I canceled this and received only 1 letter. Also, make sure that there is no end at the end of the array, as this will also result in only one letter appearing.

0
source

Remove user class =. He will begin to show it all.

-2
source

All Articles