var formElementName = $('#hostName').attr('name');
var hiddenElementID = formElementName + '_autocomplete_hidden';
$('#hostName').after("<input type=\"hidden\" name=\"" + formElementName + "ID\" id=\"" + hiddenElementID + "\" />");
$('#hostName')
.keyboard({
usePreview: false,
stayOpen : true,
maxLength : 100,
tabNavigation : true,
language: ['de'],
layout: 'ms-German',
autoAccept : true,
position : {
of : '#hostName_keyboard',
my : 'center',
at : 'center',
},
reposition : true,
css: {
container: 'center-block',
buttonDefault: 'btn btn-default btn-lg',
buttonHover: 'btn-primary',
buttonAction: 'active',
buttonDisabled: 'disabled'
}
})
.autocomplete({
source: function(query, response) {
$.ajax({
url: "controllers/visitor.cfc?method=getHosts",
dataType: "json",
data: {
searchPhrase: query.term
},
success: function(result) {
response(result);
}
});
},
minLength: 2,
select: function(event, ui) {
var selectedObj = ui.item;
$('#hostName').val(selectedObj.label);
$('#'+hiddenElementID).val(selectedObj.value);
return false;
}
,
open : function() {
$('#'+hiddenElementID).val(0);
},
close: function(){
if ($('#'+hiddenElementID).val()=='0')
$('#hostName').val('');
}
})
.addAutocomplete({
position : {
of : '#hostName',
my : 'center top',
at : 'center bottom',
collision: 'flip'
}
})
// Typing extension
.addTyping({
showTyping: true,
delay: 250
});
I think there is a issue using autocomplet with autoAccept: true
The autocomplete opens and I can select a value. The autocomplet closes and the text is in the input. But when I select a different form element on the page the input field returns to blank.
I have more input elements on the page without autocomplete and they are working fine.
It was working fine with version 1.26.6 but I had to update to 1.26.13 because of the IE11 issue in the older versions.
So this is my code: