我已经对这个问题进行了几个小时的故障排除,但都没有结果。
基本上,在下面的代码中,我从远程建议提供程序获得了正确的结果,
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>但是,当建议以搜索字符串开始时,不会显示...想法?
谢谢!
发布于 2015-04-30 09:18:34
将displayKey添加到typeahead datasets参数。
$('#bloodhound .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 0
},{
name: 'descuentos',
displayKey: 'value',
source: descuentos
});希望这能有所帮助。
https://stackoverflow.com/questions/29956945
复制相似问题