Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions tagmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},

publicMethods = {
pushTag : function (tag, ignoreEvents, externalTagId) {
pushTag : function (tag, ignoreEvents, externalTagId, ignoreValidator) {
var $self = $(this), opts = $self.data('opts'), alreadyInList, tlisLowerCase, max, tagId,
tlis = $self.data("tlis"), tlid = $self.data("tlid"), idx, newTagId, newTagRemoveId, escaped,
html, $el, lastTagId, lastTagObj;
Expand Down Expand Up @@ -82,7 +82,7 @@
}

// call the validator (if any) and do not let the tag pass if invalid
if (opts.validator && !opts.validator(tag)) {
if (!ignoreValidator && opts.validator && !opts.validator(tag)) {
$self.trigger('tm:invalid', tag)
return;
}
Expand Down Expand Up @@ -160,7 +160,11 @@
$(opts.tagsContainer).append($el);
} else {
if (tlid.length > 1) {
lastTagObj = $self.siblings("#" + $self.data("tm_rndid") + "_" + tlid[tlid.length - 2]);
var lastTagObjSelector = "#" + $self.data("tm_rndid") + "_" + tlid[tlid.length - 2];
// If there's a typeahead, we'll need to go up one element
lastTagObj = $self.siblings(lastTagObjSelector).length > 0
&& $self.siblings(lastTagObjSelector)
|| $self.parent().siblings(lastTagObjSelector);
lastTagObj.after($el);
} else {
$self.before($el);
Expand Down Expand Up @@ -306,9 +310,9 @@
var opts = $self.data('opts')
$.each(pta, function (key, val) {
if (opts.externalTagId === true) {
publicMethods.pushTag.call($self, val[opts.prefillValueFieldName], true, val[opts.prefillIdFieldName]);
publicMethods.pushTag.call($self, val[opts.prefillValueFieldName], true, val[opts.prefillIdFieldName], true);
} else {
publicMethods.pushTag.call($self, val, true);
publicMethods.pushTag.call($self, val, true, false, true);
}
});
},
Expand Down