make sure to get proper tag value + use selected tag if possible

This commit is contained in:
Daku 2016-06-19 09:49:55 +01:00
parent ce10831137
commit 03240220d4

View File

@ -47,10 +47,9 @@ $(function(){
} else if (keyCode == 9) {
e.preventDefault();
var tag = $('.tagit-autocomplete[style*=\"display: block\"] > li:first').text();
if(tag){
$('[name=search]').tagit('createTag', tag);
$('.ui-autocomplete-input').autocomplete('close');
var tag = $('.tagit-autocomplete[style*=\"display: block\"] > li:focus, .tagit-autocomplete[style*=\"display: block\"] > li:first').first();
if(tag.length){
$(tag).click();
$('.ui-autocomplete-input').val(''); //If tag already exists, make sure to remove duplicate.
}
}