谁能看到我在这里做错了什么?我花了很长时间研究各种各样的预输入代码。从我可以选择的 Json 调用中返回值,但我需要设置 Id 隐藏字段。我在更新程序功能(日志、警报等)中尝试了各种方法,但 zip。我相信它不会触发。
var teamNames = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('Text'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: 'List'
});
teamNames.initialize();
$('#remote #FullName').typeahead(null, {
name: 'team-names',
displayKey: 'Text',
source: teamNames.ttAdapter(),
updater: function(item){$('#Id').val(map[item].Value)}
})
非常感谢您的任何意见。如果您认为自己有答案,请设置为答案,以便我承认 - 干杯。
更新 - 我怀疑我使用了一些过时或不兼容的代码。我现在已经使用
$('#FullName').bind('typeahead:selected', function (obj, datum, name) {}
我在 GitHub 上找到的,谢谢 andy3rdworld,效果很好