我正在使用 bootstrap-typeahead 和rails4。
我可以获得下拉功能,但是当我向上和向下按时,我不希望所选值填充输入。我该如何实现这个?
我尝试了一些解决方案,但没有成功。 How to prevent Twitter typeahead from filling in the input with the selected value?
相关代码:
$("#nav_search").typeahead({
items: 6,
source:numbers.ttAdapter(),
displayText: function(data){
// console.log(data);
return '<div><strong>'+data.username+'</strong>'+'-'+data.position+' at '+data.company+'</div>';
},
fitToElement: true,
afterSelect: function(data){
window.location.href=data.url;
}
})
最佳答案
我设法使用它来解决它
.on('keyup', this, function (event){
if(event.which==38 || event.which==40) $(#nav_search).val(...)}
);
关于jquery - 如何防止 typeahead 用所选值填充输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47524167/