Skip to content

Commit

Permalink
Fix bug Pixabay#155
Browse files Browse the repository at this point in the history
  • Loading branch information
Фадеев Андрей Евгеньевич authored and Фадеев Андрей Евгеньевич committed Jul 19, 2019
1 parent e843e1d commit 350cf93
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions jquery.tag-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,15 @@
tag = cb_val || tag;
if (cb_val === false || !tag) continue;
// remove duplicates
if (o.removeDuplicates && ~$.inArray(tag, old_tags))
$('.tag-editor-tag', ed).each(function(){ if ($(this).text() == tag) $(this).closest('li').remove(); });
old_tags.push(tag);
var oldIndex = old_tags.indexOf(tag);
if (o.removeDuplicates && oldIndex >= 0) {
$('.tag-editor-tag', ed).each(function(index, element){
if ($(element).text() == tag && index != oldIndex) {
$(element).closest('li') && $(element).closest('li').remove();
}
});
}
else old_tags.push(tag);
li.before('<li><div class="tag-editor-spacer">&nbsp;'+o.delimiter[0]+'</div><div class="tag-editor-tag">'+escape(tag)+'</div><div class="tag-editor-delete"><i></i></div></li>');
if (o.maxTags && old_tags.length >= o.maxTags) { exceeded = true; break; }
}
Expand Down

0 comments on commit 350cf93

Please sign in to comment.