twitter / typeahead.js

typeahead.js is a fast and fully-featured autocomplete library
http://twitter.github.io/typeahead.js/
MIT License
16.52k stars 3.2k forks source link

sometimes no suggestion without error, but ajax results are loaded #1738

Open 4d4ch4u32 opened 6 years ago

4d4ch4u32 commented 6 years ago

Hi, I have an typeahead autosuggest created, with bloodhound.

Bloodhound-Code:

var addresses = new Bloodhound({
    datumTokenizer: Bloodhound.tokenizers.whitespace,
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    remote: {
        url: Routing.generate('manage_ajax_addresses_search') + '?q=%QUERY',
        wildcard: '%QUERY',
        cache: false
    },
    prefetch: {
        url: Routing.generate('manage_ajax_addresses_search')
    }
});

Typeahead initialization code:

$('#input').typeahead(null, {
    name: 'addresses',
    source: addresses,
    display: 'search',
    minLength: 0,
    items: 99999,
    autoSelect: true,
    showHintOnFocus: true,
    templates: {
        suggestion: function (data) {
            return '<div>' + data.company + '<small>' + data.address + ', ' + data.zip + ' ' + data.city + '</small></div>';
        },
        pending: function (data) {
            return '<div style="padding: 4px;"><img src="https://cdn.wwnbg.de/img/ajax-loader/ajax-loading-truck.gif" height="30px;" <i>Suche läuft...</i></div>';
        },
        notFound: function (data) {
            return '<div style="padding: 4px;"><small><i>Keine passenden Einträge gefunden.</i></small></div>';
        },
        header: function (data) {
            return '';
        }
    }
});

However, when I type "Made" in the input, entries are loaded that contain this string. If I enter "Mader", the Ajax request is executed, which returns results that are correct, but the autosuggest displays "No entries found". How can I fix this?

wni5378 commented 6 years ago

Hi there,

I'm experiencing the same issue but instead of "Mader", typeahead.js is not returning anything when I use the word "info" despite there being 74 results.

cbilgili commented 5 years ago

Hello,

I had same problem. For me using another fork worked; https://github.com/mattywong/typeahead.js