diff --git a/tagmanager.js b/tagmanager.js index e280f4b..e494505 100644 --- a/tagmanager.js +++ b/tagmanager.js @@ -155,7 +155,11 @@ $el.find("#" + newTagRemoveId).on("click", $self, function(e) { e.preventDefault(); - var TagIdToRemove = parseInt($(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); }); @@ -190,8 +194,13 @@ // console.log(tlis); } }, + + removeTagByID : function (TagID) { + var $self = this; + 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) { @@ -202,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) { @@ -213,6 +224,12 @@ tags : function() { var $self = this, tlis = $self.data("tlis"); return tlis; + }, + + // Return tags ID + tags_id: function() { + var $self = this, tlid = $self.data("tlid"); + return tlid; } }, @@ -318,6 +335,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); }