Browse files

Implemented removeTag method

  • Loading branch information...
1 parent ecec3c7 commit 35cf3e2016e07a3c485c9d57d4886e7e41620482 @nikku committed Sep 3, 2011
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/jquery.tagit.js
View
16 lib/jquery.tagit.js
@@ -67,7 +67,6 @@
// Tag already added
if (selection.length) {
- self.trigger("tagit-tag-added");
return;
}
@@ -103,7 +102,20 @@
element.insertBefore($(".tagit-edit-handle", self));
}
- self.trigger("tagit-tag-added");
+ self.trigger("tagit-tag-added", [tag]);
+ },
+
+ removeTag: function(tag) {
+ var self = $(this);
+
+ var selection = self.find("input[type=hidden]").filter(function() {
+ return $(this).val() == tag;
+ });
+
+ if (selection.length) {
+ selection.parent().remove();
+ self.trigger("tagit-tag-removed", [tag]);
+ }
},
getTags: function() {

0 comments on commit 35cf3e2

Please sign in to comment.