0

I've been troubleshooting this for couple hours to no avail.

Basically, in the following code, I get the right results from the remote suggestions provider,

            var descuentos = new Bloodhound({
            datumTokenizer: Bloodhound.tokenizers.nonword,
            queryTokenizer: Bloodhound.tokenizers.nonword,
            remote: {
                url: 'http://localhost:30045/Home/Suggest?q=%QUERY&type=name&fuzzy=false',
                wildcard: "%QUERY",
                filter: function (items) {
                    return $.map(items, function (item) {
                        return {
                            value: item.NombreComercio
                        };
                    });
                }
            }
        });

        $('#bloodhound .typeahead').typeahead({
            hint: true,
            highlight: true,
            minLength: 0
        },
        {
            name: 'descuentos',
            source: descuentos
        });

<body>
    <div id="bloodhound">
        <input class="typeahead" type="text" placeholder="Comercio Adherido...">
    </div>
</body>

But, when the suggestion STARTS WITH the search string, is not displayed... Ideas?

Thanks!

Ariel
  • 5,752
  • 5
  • 49
  • 59

1 Answers1

0

Add displayKey to typeahead datasets parameter.

$('#bloodhound .typeahead').typeahead({
  hint: true,
  highlight: true,
  minLength: 0
},{
  name: 'descuentos',
  displayKey: 'value',
  source: descuentos
});

Hope this helps.

Dhiraj
  • 33,140
  • 10
  • 61
  • 78