Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

new event: onTagsSet #10

Closed
wants to merge 4 commits into from

1 participant

@jmikkola

Added an event called onTagsSet that is called after the DOM is modified whenever tags are changed.

(I created it so that I could make the field auto-submit.)

@jmikkola jmikkola closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 1 deletion.
  1. +11 −0 README.markdown
  2. +10 −1 js/tag-it.js
View
11 README.markdown
@@ -183,6 +183,17 @@ The function receives the click event and the tag as parameters.
}
});
+### onTagsSet (function, Callback)
+
+Can be used to add custom behaviour after a Tag has been added to
+or removed from the DOM. The function receives an empty event.
+
+ $("#mytags").tagit({
+ onTagsSet: function(event) {
+ // do something special
+ }
+ });
+
## Methods
View
11 js/tag-it.js
@@ -72,7 +72,10 @@
// Event callbacks.
onTagAdded : null,
onTagRemoved: null,
- onTagClicked: null
+ onTagClicked: null,
+
+ // Callback for submitting tags when changed
+ onTagsSet: null,
},
@@ -338,6 +341,8 @@
// insert tag
this._tagInput.parent().before(tag);
+
+ this._trigger('onTagsSet', null);
},
removeTag: function(tag, animate) {
@@ -363,6 +368,8 @@
} else {
tag.remove();
}
+
+ this._trigger('onTagsSet', null);
},
removeAll: function() {
@@ -371,6 +378,8 @@
this.tagList.children('.tagit-choice').each(function(index, tag) {
that.removeTag(tag, false);
});
+
+ this._trigger('onTagsSet', null);
}
});
Something went wrong with that request. Please try again.