Skip to content

Commit

Permalink
fix removeTagByName for singleField
Browse files Browse the repository at this point in the history
  • Loading branch information
aehlke committed Nov 25, 2012
1 parent f2ec4f6 commit 15f298b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions js/tag-it.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,20 +352,20 @@
this.tagInput.autocomplete('search', '');
},

_existingTag: function(value) {
_findTagByName: function(name) {
var that = this;
var tag = null;
this._tags().each(function(i) {
if (that._formatStr(value) == that._formatStr(that.tagLabel(this))) {
if (that._formatStr(name) == that._formatStr(that.tagLabel(this))) {
tag = $(this);
return false;
}
});
return tag;
},

_isNew: function(value) {
return !this._existingTag(value);
_isNew: function(name) {
return !this._findTagByName(name);
},

_formatStr: function(str) {
Expand All @@ -389,7 +389,7 @@
}

if (!this.allowDuplicates && !this._isNew(value)) {
var existingTag = this._existingTag(value);
var existingTag = this._findTagByName(value);
if (this._trigger('onTagExists', null, {
existingTag: existingTag,
duringInitialization: duringInitialization
Expand Down Expand Up @@ -493,8 +493,8 @@
},

removeTagByName: function(tagName, animate) {
var toRemove = this._tags().find("input[value='" + tagName + "']").closest('.tagit-choice');
if (toRemove.length === 0) {
var toRemove = this._findTagByName(tagName);
if (!toRemove) {
throw "No such tag exists with the name '" + tagName + "'";
}
this.removeTag(toRemove, animate);
Expand Down
12 changes: 6 additions & 6 deletions js/tag-it.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 15f298b

Please sign in to comment.