0

私はこれを数時間トラブルシューティングしてきましたが、役に立ちませんでした。

基本的に、次のコードでは、リモート提案プロバイダーから正しい結果を取得します。

            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>

しかし、提案が検索文字列で始まる場合、表示されません...アイデア?

ありがとう!

4

1 に答える 1

0

displayKey先行入力データセット パラメーターに追加します。

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

お役に立てれば。

于 2015-04-30T01:18:34.120 に答える