我正在使用Jquery AutoComplete并在我做出第一个选择然后离开文本框然后如果我再来到相同的第一个文本框它会自动调用onSelecting
$('#autocomplete-ajax1').autocomplete({
lookup: countriesArray,
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
var re = new RegExp('\\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi');
return re.test(suggestion.value);
},
onSelect: function (suggestion) {
debugger;
//$('#autocomplete-ajax1').val($('#autocomplete-ajax1').val().trim());
AutoFill(suggestion.value);
$('#selction-ajax1').val(suggestion.data);
}
});
Jquery.js:1.9.1 jquery-ui-1.9.2.custom.js:1.9.2
答案 0 :(得分:0)
问题在于自动填充的选项中的triggerSelectOnValidInput,只要找到与文本框值匹配的匹配,就会触发选择
$('#autocomplete-ajax1').autocomplete({
triggerSelectOnValidInput :false,
lookup: countriesArray,
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
var re = new RegExp('\\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi');
return re.test(suggestion.value);
},
onSelect: function (suggestion) {
debugger;
//$('#autocomplete-ajax1').val($('#autocomplete-ajax1').val().trim());
AutoFill(suggestion.value);
$('#selction-ajax1').val(suggestion.data);
}
});