Permalink
Browse files

fix beforeTagAdded callback timing for singleField

  • Loading branch information...
aehlke committed Nov 27, 2012
1 parent 5ba933a commit d5fe008090b03a9a40dd2e1c8a257ddb69cad3b3
Showing with 14 additions and 12 deletions.
  1. +10 −8 js/tag-it.js
  2. +4 −4 js/tag-it.min.js
View
@@ -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),
@@ -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.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit d5fe008

Please sign in to comment.