【问题标题】:Bloodhound - typeahead not showing suggestions that start with the typed search stringBloodhound - 预输入不显示以输入的搜索字符串开头的建议
【发布时间】:2015-07-09 12:27:07
【问题描述】:

我已经解决了几个小时,但无济于事。

基本上,在下面的代码中,我从远程建议提供者那里得到了正确的结果,

            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>

但是,当建议以搜索字符串开头时,不显示...想法?

谢谢!

【问题讨论】:

    标签: typeahead bloodhound


    【解决方案1】:

    displayKey 添加到预输入数据集参数。

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

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-18
      相关资源
      最近更新 更多