Skip to content

Commit

Permalink
add tagLabel to before/afterTagAdded/Removed callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
aehlke committed Nov 25, 2012
1 parent 15f298b commit f9e18a4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
20 changes: 14 additions & 6 deletions js/tag-it.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@
tagLabel: function(tag) {
// Returns the tag's string label.
if (this.options.singleField) {
return $(tag).children('.tagit-label').text();
return $(tag).find('.tagit-label:first').text();
} else {
return $(tag).children('input').val();
return $(tag).find('input:first').val();
}
},

Expand Down Expand Up @@ -439,7 +439,11 @@
// DEPRECATED.
this._trigger('onTagAdded', null, tag);

if (this._trigger('beforeTagAdded', null, {tag: tag, duringInitialization: duringInitialization}) === false) {
if (this._trigger('beforeTagAdded', null, {
tag: tag,
tagLabel: this.tagLabel(tag),
duringInitialization: duringInitialization
}) === false) {
return;
}

Expand All @@ -448,7 +452,11 @@
// Insert tag.
this.tagInput.parent().before(tag);

this._trigger('afterTagAdded', null, {tag: tag, duringInitialization: duringInitialization});
this._trigger('afterTagAdded', null, {
tag: tag,
tagLabel: this.tagLabel(tag),
duringInitialization: duringInitialization
});

if (this.options.showAutocompleteOnFocus && !duringInitialization) {
setTimeout(function () { that._showAutocomplete(); }, 0);
Expand All @@ -463,7 +471,7 @@
// DEPRECATED.
this._trigger('onTagRemoved', null, tag);

if (this._trigger('beforeTagRemoved', null, {tag: tag}) === false) {
if (this._trigger('beforeTagRemoved', null, {tag: tag, tagLabel: this.tagLabel(tag)}) === false) {
return;
}

Expand All @@ -489,7 +497,7 @@
tag.remove();
}

this._trigger('afterTagRemoved', null, {tag: tag});
this._trigger('afterTagRemoved', null, {tag: tag, tagLabel: this.tagLabel(tag)});
},

removeTagByName: function(tagName, animate) {
Expand Down
14 changes: 7 additions & 7 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 f9e18a4

Please sign in to comment.