【发布时间】:2015-03-04 18:24:21
【问题描述】:
我正在使用 Twitter Typeahead 并且在悬停建议时遇到一些问题,这会触发悬停的建议弹出到我的输入字段中。如果用户然后按下输入,将选择实际悬停的值,而不是用户写的内容。我希望仅当用户单击实际建议时才选择它。 好像是
_onSuggestionMouseEnter()
当鼠标悬停在建议上时触发的函数。我的问题是是否可以在我自己的代码中覆盖这个函数?或者用其他方式解决这个问题?
这是我的预输入代码:
var suggestions = new Bloodhound({
datumTokenizer: function(d) {
return Bloodhound.tokenizers.whitespace(d.value);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 100,
remote: {
url: 'url/to/suggestions',
filter: function(list) {
return $.map(list.suggestions, function(word) {
return {s: word.title};
});
}
}
});
suggestions.initialize();
$('.typeahead').typeahead({highlight: true}, {
source: suggestions.ttAdapter(),
name: 'suggestions',
displayKey: 's',
hint: false
})
【问题讨论】:
标签: javascript jquery twitter typeahead