Skip to content

Commit

Permalink
fix beforeTagAdded callback timing for singleField
Browse files Browse the repository at this point in the history
  • Loading branch information
aehlke committed Nov 27, 2012
1 parent 5ba933a commit d5fe008
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
18 changes: 10 additions & 8 deletions js/tag-it.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,18 +427,11 @@
}

// Unless options.singleField is set, each tag has a hidden input field inline.
if (this.options.singleField) {
var tags = this.assignedTags();
tags.push(value);
this._updateSingleTagsField(tags);
} else {
if (!this.options.singleField) {
var escapedValue = label.html();
tag.append('<input type="hidden" style="display:none;" value="' + escapedValue + '" name="' + this.options.fieldName + '" />');
}

// DEPRECATED.
this._trigger('onTagAdded', null, tag);

if (this._trigger('beforeTagAdded', null, {
tag: tag,
tagLabel: this.tagLabel(tag),
Expand All @@ -447,6 +440,15 @@
return;
}

if (this.options.singleField) {
var tags = this.assignedTags();
tags.push(value);
this._updateSingleTagsField(tags);
}

// DEPRECATED.
this._trigger('onTagAdded', null, tag);

this.tagInput.val('');

// Insert tag.
Expand Down
8 changes: 4 additions & 4 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 d5fe008

Please sign in to comment.