Skip to content

Commit 85c0091

Browse files
committed
Fix autocomplete when source is a flat array e.g. ["tag1", "tag2"],
not an object with id and label items. In such case tag id is a number not a string.
1 parent d9799eb commit 85c0091

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

js/jquery.tagedit.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@
167167
var checkAutocomplete = oldValue == true? false : true;
168168
// check if the Value ist new
169169
var isNewResult = isNew($(this).val(), checkAutocomplete);
170-
if(isNewResult[0] === true || (isNewResult[0] === false && typeof isNewResult[1] == 'string')) {
170+
if(isNewResult[0] === true || isNewResult[1] != null) {
171171

172-
if(oldValue == false && typeof isNewResult[1] == 'string') {
172+
if(oldValue == false && isNewResult[1] != null) {
173173
oldValue = true;
174174
id = isNewResult[1];
175175
}
@@ -446,7 +446,7 @@
446446
var label = options.checkNewEntriesCaseSensitive == true? result[i].label : result[i].label.toLowerCase();
447447
if (label == compareValue) {
448448
isNew = false;
449-
autoCompleteId = result[i].id;
449+
autoCompleteId = typeof result[i] == 'string' ? i : result[i].id;
450450
break;
451451
}
452452
}

0 commit comments

Comments
 (0)