Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to fetch movies from api/movies. but typeahead.js is getting only the first record from the database and not the others. I put autosuggestion on the text box.

What I have tried:

here is the text box for movie
JavaScript
<pre><div class="form-group">
        <label>Movie</label>
        <input id="movie" type="text" value="" class="form-control" />
    </div>


here is the javascript code for using type a head

var movies = new Bloodhound({
               datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
               queryTokenizer: Bloodhound.tokenizers.whitespace,
               remote: {
                   url: '/api/movies?query=%QUERY',
                   wildcard: '%QUERY'
               }
           });

           $('#movie').typeahead({
               minLenght: 3,
               highlight: true
           }, {
               name: 'movies',
               display: 'name',
               source: movies
           });
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900