gpt4 book ai didi

javascript - 如何限制从键盘中选择的提前输入选项?

转载 作者:行者123 更新时间:2023-11-28 04:10:41 26 4
gpt4 key购买 nike

我的输入如下,

<input
typeahead-template-url="app/templates/type-a-head-item.html"
type="text"
ng-model="selectedDisease"
search-head="powerSearch"
typeahead-loading="loadingLocations"
typeahead-wait-ms="200"
typeahead-min-length="0"
placeholder="Disease, Procedure or Medicine"
typeahead="match as match._source.name for match in getDiseases($viewValue)"
typeahead-focus-first="false"
typeahead-editable="false"
typeahead-loading="loadingDiseases"
class="form-control input-lg ng-pristine ng-untouched ng-invalid ng-invalid-required magnifyInput Bcolor"
typeahead-on-select="searchDoctors()"
aria-autocomplete="list"
aria-expanded="false"
aria-owns="typeahead-12-6891">

我只想从下拉列表中选择选项,而不是通过键盘输入来选择它。我尝试了很多使用 jQuery 的方法,但没有成功。有人可以建议我帮忙吗。谢谢。

$(document).keypress(function(e) {
if(e.which == 13) {
alert('You pressed enter!');
}
});

最佳答案

添加此属性应该可以实现您想要的行为:

typeahead-should-select="false"

来自docs :

typeahead-should-select($event) (Default: null)

A callback executed when a keyup event that might trigger a selection occurs. Selection will only occur if this function returns true.

关于javascript - 如何限制从键盘中选择的提前输入选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46298687/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com