我在网站上使用了angluarJS和Jquery。但是我有问题。 重新加载页面时,我可以使用F4键进行焦点输入并搜索客户
当我在外面单击然后按F4时,输入文本搜索不起作用,但单击输入则可以正常工作。那么我该如何解决呢? 请帮我。谢谢。 我的HTML
<input id="customerSearchInput" placeholder="Tìm kiếm khách hàng (F4)" type="text" class="form-control" focus-me="shouldBeOpen"
aria-label="Customer" ng-model="searchCustomer" onfocus="this.select();" autocomplete="off"/>
<div class="output-complete output-complete-customer " ng-show="searchCustomer">
<ul ng-hide="searchCustomer && list_customer.length == 0">
<li
ng-repeat="suggestion in list_customer|filter:searchCustomer|filter:suggestion.customer_code"
ng-click="customerClicked(suggestion)" index="$index" class="">
<span class="pull-right">{{suggestion.mobile}}</span>
<div class="user-info">
<span class="name-info">{{suggestion.name}}</span>
<span>Mã: {{suggestion.customer_code}}</span>
</div>
</li>
</ul>
<div class="not-found"
ng-show="searchCustomer && suggestion.length == 0">Không tìm
thấy khách hàng phù hợp
</div>
</div>
AngularJS
$(()=>{
$(document).on('keydown', function (event) {
if (event.which == 115 && event.target.id != 'customerSearchInput') {
setTimeout(function(){
$("#customerSearchInput").focus().select();
},300);
}
});
})