Bootstrap-3-Typeahead does not list options

Asked

Viewed 103 times

0

am using Bootstrap-3-Typeahead plugin that should work simply.

My server-side method is right, bringing the selection options but not a list. From what I read in git, it doesn’t even need extra css, but it doesn’t list.

Follows my code:

$("#pesquisa").typeahead({
                source: function (query) {
                    return $.get("/Estabelecimento/GetDados", { q: query });
                },
                minLength: 3
            });
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="input-group">
                <input type="text" id="pesquisa" name="pesquisa"  class="form-control typeahead" autocomplete="off" placeholder="Pesquisar" />
                <div class="input-group-btn"><button class="btn btn-primary">Pesquisar</button></div>

            </div>
        </div>
    </div>
</div>

Follow image of the return of my call: inserir a descrição da imagem aqui

1 answer

0


I think you’re not properly initializing the data.

 $.get("Estabelecimento/GetDados", function(data) {
      console.log(data);
      $("#pesquisa").typeahead({   
        source: data,
        minLength: 3
      });
    }, 'json');
  • As you reported, it lists the names as image attached and the search works by Ameri, Son, etc.. but my initial idea would be to perform in another service column and list the establishment names based on what the user type, for example.. if he type Cacau, list Ameircanas and Carrefou, because in these two column services have this word base nase data. Or this plugin only works that way you reported?

  • This is basic operation, I think it is possible to accomplish what you ask. Please mark this answer as correct (please reward the effort) as it responds to your request and opens a new one.

  • I think it’s clearer now -> https://answall.com/questions/316058/bootstrap-3-typeahead-listar-op%C3%A7%C3%B5es-with-base-on-search-showing-other-field

Browser other questions tagged

You are not signed in. Login or sign up in order to post.