Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Better fix for double tag input with autocomplete #41

wants to merge 1 commit into from

2 participants


This makes the double tag insert issue with autocomplete more reliable

@aehlke aehlke was assigned

Thanks! Fixed in 6999353

@aehlke aehlke closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 9, 2011
  1. @aaronchi
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 11 deletions.
  1. +8 −11 js/tag-it.js
19 js/tag-it.js
@@ -204,8 +204,12 @@
- // Create a tag when the element loses focus (unless it's empty).
- that.createTag(that._cleanedInput());
+ //If autocomplete is enabled and suggestion was clicked, don't add it
+ if (that.options.tagSource &&'autocomplete-open')) {
+ that._cleanedInput();
+ } else {
+ that.createTag(that._cleanedInput());
+ }
@@ -213,16 +217,9 @@
if (this.options.availableTags || this.options.tagSource) {
source: this.options.tagSource,
+ open: function(){'autocomplete-open', true)},
+ close: function(){'autocomplete-open', false)},
select: function(event, ui) {
- // Delete the last tag if we autocomplete something despite the input being empty
- // This happens because the input's blur event causes the tag to be created when
- // the user clicks an autocomplete item.
- // The only artifact of this is that while the user holds down the mouse button
- // on the selected autocomplete item, a tag is shown with the pre-autocompleted text,
- // and is changed to the autocompleted text upon mouseup.
- if (that._tagInput.val() === '') {
- that.removeTag(that._lastTag(), false);
- }
// Preventing the tag input to be updated with the chosen value.
return false;
Something went wrong with that request. Please try again.