JqueryUI自动完成function可防止每次按键调用
我正在使用JqueryUI Autocomplete,我想要做的是防止JqueryUI自动完成在每个按键上调用。 一切都在以完美的方式运作。 我已经将文本字段与自动完成绑定,但是在每次按键时它都会进行调用。 如何防止特定键上的呼叫? 例如,我想阻止对箭头键的调用。 这是我在Coffee中的代码。
$("#location-search").autocomplete source: (request, response) -> if request.term.length rows = new Array() data = data.geonames i = 0 while i 0 $("#location-search").parent().find(".pen-dropdown ul").append(" All Area ") for row, i in rows $("#location-search").parent().find(".pen-dropdown ul").append(" #{row['value']}, #{row['country_code']} ") window.dropdownli = $(".pen-dropdown li") window.dropdownliSelected = undefined for li in $("#location-search").parent().find(".pen-dropdown ul li") $(li).click(setLocationTitle) $("#location-search").parent().find(".pen-dropdown").show()
谢谢
我有类似的问题。 我在自动完成中使用事件“ search(event,ui) ”修复它。
$("#autocompleteText").autocomplete({ search: function (event, ui) { /*keyCode will "undefined" if user presses any function keys*/ if(event.keyCode) { event.preventDefault(); } }, autoFocus:false, minLength:3, source: function (request, response) { //make remote call for result. } });