From 512e95f8c9f9979e7a3de89102d55ca293069f76 Mon Sep 17 00:00:00 2001 From: Bijk Date: Thu, 1 May 2014 12:26:38 -0700 Subject: [PATCH 1/6] Update Fix for option externalTagId: true Can't remove tag with custom ID # var TagIdToRemove = parseInt($(this).attr("TagIdToRemove")); + tagsManager('tags_id') Return ID of tag elements --- tagmanager.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tagmanager.js b/tagmanager.js index e280f4b..f3ac420 100644 --- a/tagmanager.js +++ b/tagmanager.js @@ -155,7 +155,7 @@ $el.find("#" + newTagRemoveId).on("click", $self, function(e) { e.preventDefault(); - var TagIdToRemove = parseInt($(this).attr("TagIdToRemove")); + var TagIdToRemove = $(this).attr("TagIdToRemove"); privateMethods.spliceTag.call($self, TagIdToRemove, e.data); }); @@ -213,6 +213,12 @@ tags : function() { var $self = this, tlis = $self.data("tlis"); return tlis; + }, + + // Return tags ID + tags_id: function() { + var $self = this, tlis = $self.data("tlid"); + return tlis; } }, From 34c609047f0b6e0490b357fb134f04eadae9de4f Mon Sep 17 00:00:00 2001 From: Bijk Date: Thu, 1 May 2014 12:30:42 -0700 Subject: [PATCH 2/6] Update tagmanager.js --- tagmanager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tagmanager.js b/tagmanager.js index f3ac420..56fa829 100644 --- a/tagmanager.js +++ b/tagmanager.js @@ -216,9 +216,9 @@ }, // Return tags ID - tags_id: function() { - var $self = this, tlis = $self.data("tlid"); - return tlis; + tags_id: function() { + var $self = this, tlid = $self.data("tlid"); + return tlid; } }, From a78166d617b95b00a7b3038534ebb3d68de074af Mon Sep 17 00:00:00 2001 From: Bijk Date: Thu, 1 May 2014 13:11:23 -0700 Subject: [PATCH 3/6] Update tagmanager.js --- tagmanager.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tagmanager.js b/tagmanager.js index 56fa829..6a3519f 100644 --- a/tagmanager.js +++ b/tagmanager.js @@ -155,7 +155,11 @@ $el.find("#" + newTagRemoveId).on("click", $self, function(e) { e.preventDefault(); - var TagIdToRemove = $(this).attr("TagIdToRemove"); + if (opts.externalTagId === true) { + var TagIdToRemove = $(this).attr("TagIdToRemove"); + } else { + var TagIdToRemove = parseInt($(this).attr("TagIdToRemove")); + } privateMethods.spliceTag.call($self, TagIdToRemove, e.data); }); From ffca1618b39349f51e9f376314e1a193fb9a28a5 Mon Sep 17 00:00:00 2001 From: Bijk Date: Thu, 1 May 2014 13:45:40 -0700 Subject: [PATCH 4/6] Added function removeTagByID .tagsManager("removeTagByID",'tag_html_id'); --- tagmanager.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tagmanager.js b/tagmanager.js index 6a3519f..c13968a 100644 --- a/tagmanager.js +++ b/tagmanager.js @@ -194,6 +194,11 @@ // console.log(tlis); } }, + + removeTagByID : function (TagID) { + var $self = this; + privateMethods.spliceTag.call($self,TagID); + }, empty : function() { var $self = $(this), tlis = $self.data("tlis"), tlid = $self.data("tlid"), tagId; From 63af39a5d9c2d7b2e0aedd9d7b3ca91fd1bbcd84 Mon Sep 17 00:00:00 2001 From: Bijk Date: Sat, 3 May 2014 07:34:20 -0700 Subject: [PATCH 5/6] Update tagmanager.js --- tagmanager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tagmanager.js b/tagmanager.js index c13968a..1a91a11 100644 --- a/tagmanager.js +++ b/tagmanager.js @@ -333,6 +333,10 @@ tlid.splice(idx, 1); privateMethods.refreshHiddenTagList.call($self); $self.trigger('tm:spliced', [tagBeingRemoved, tagId]); + + if (tlis.length == 0) { + $self.trigger('tm:empty', null); + } // console.log(tlis); } From ded04aa78d4d598de43be799c54938b42b3b99b1 Mon Sep 17 00:00:00 2001 From: Bijk Date: Sat, 3 May 2014 08:25:17 -0700 Subject: [PATCH 6/6] optionally send trigger on empty tag list empty : function(send_trigger) default:true Example: $( "#tags_input" ).on( "tm:emptied", function() { alert('cleared'); }); .tagsManager("empty"); // alert('cleared'); .tagsManager("empty",false); // no alert --- tagmanager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tagmanager.js b/tagmanager.js index 1a91a11..e494505 100644 --- a/tagmanager.js +++ b/tagmanager.js @@ -200,7 +200,7 @@ privateMethods.spliceTag.call($self,TagID); }, - empty : function() { + empty : function(send_trigger) { var $self = $(this), tlis = $self.data("tlis"), tlid = $self.data("tlid"), tagId; while (tlid.length > 0) { @@ -211,7 +211,9 @@ privateMethods.refreshHiddenTagList.call($self); // console.log(tlis); } - $self.trigger('tm:emptied', null); + + send_trigger = (typeof send_trigger === "undefined") ? true : send_trigger; + if (send_trigger === true) $self.trigger('tm:emptied', null); privateMethods.showOrHide.call($self); //if (tagManagerOptions.maxTags > 0 && tlis.length < tagManagerOptions.maxTags) {