Bootstrap-3-Typeahead icon indicating copy to clipboard operation
Bootstrap-3-Typeahead copied to clipboard

suggestion list not being shown

Open aidonsnous opened this issue 7 years ago • 1 comments

I follow the documentation but nothing is working for me. I am loading my data from remote :

Here is the structure of data coming from remote:

{"source":[{id:1,name:"coke"},{id:2,name:"papa"},{id:3,name:"mama"}]} on client side here is my first code I tried with :


var typeaheadInput = $('input[name=name]');
       typeaheadInput.typeahead({
           source: function (query) {
               if (query.length > 3) {
                   return $.get('/suggestproduct/' + query, function (data) {
                       return data.source;
                   });
               }
           },autoSelect:true
       });

Nothing worked with that code. The information are reaching the browser but are not being shown.

What I want is to show to the user the value of name field and pass id value of the selected to a hidden field.

How can I acheive that?

aidonsnous avatar Apr 28 '17 04:04 aidonsnous

Try with the following code:

 var typeaheadInput = $('input[name=name]');
 typeaheadInput.typeahead({
     autoSelect:true,
     minLength: 3,
     source: function (query, process) {
         return $.get('/suggestproduct/' + query, function (data) {
             process(data.source);
         });
     }
 });

iruy avatar May 08 '17 09:05 iruy