I was able to solve the problem of entering the auto-focused suggestion by making some of the following in the tag-it.js file:
Defined a variable for receiving the value of focused suggestion on line 113 just after var that = this;
:
var that = this;
var focuse;
On or after line 279 and function - this.tagInput.keydown(function(event) {})
, the following has to be added:
.on( "autocompletefocus", function( event, ui ) {
focuse = ui.item.value;
})
Then finally within the function this.tagInput.keydown(function(event) {})
, replace that.createTag(that._cleanedInput());
with:
if (focuse !== '' && event.which === $.ui.keyCode.ENTER)
{
that.createTag(focuse);
focuse = '';
}
else
{
that.createTag(that._cleanedInput());
}
To enable to autofocus, add the autocomplete (autocomplete: {autoFocus: true}
) option in the file that calls the tagit plugin as:
$("#tags").tagit({
availableTags : availableTags,
autocomplete: {autoFocus: true}
});