2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-25 22:27:39 +00:00

Added hideOnSelectDisabled option to prevent suggestion box to hide when select. Very useful when using changeInputDisabled is true.

This commit is contained in:
Emerson Macedo 2014-02-21 16:13:58 -03:00
parent d110e29cf4
commit e5c457b694
2 changed files with 23 additions and 1 deletions

View File

@ -543,6 +543,27 @@ describe('Autocomplete', function () {
expect(suggestionData).toBeNull();
});
it('Should NOT hide suggestions when options.hideOnSelectDisabled is true and item is selected', function() {
$('.autocomplete-suggestions').remove();
var input = $('<input />'),
instance,
suggestionData = null;
input.autocomplete({
lookup: [{ value: 'Jamaica', data: 'J' }],
hideOnSelectDisabled: true
});
input.val('J');
instance = input.autocomplete();
instance.onValueChange();
instance.select(0);
expect($('.autocomplete-suggestions').is(':visible')).toBeTruthy();
});
describe('options.changeInputDisabled is true', function() {
var input = $('<input />'),
instance,

View File

@ -78,6 +78,7 @@
triggerSelectOnValidInput: true,
preventBadQueries: true,
changeInputDisabled: false,
hideOnSelectDisabled: false,
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
},
@ -697,7 +698,7 @@
select: function (i) {
var that = this;
that.hide();
if (!that.options.hideOnSelectDisabled) { that.hide(); }
that.onSelect(i);
},