input-pill: Add "onPillRemove" callback.

This will now allow a callback to be triggered when a pill is
removed from the set.
This commit is contained in:
Brock Whittaker 2017-12-18 10:36:00 -08:00 committed by showell
parent c2a41c268f
commit 511f2f3db4

View File

@ -135,7 +135,12 @@ var input_pill = function ($parent) {
if (typeof idx === "number") {
store.pills[idx].$element.remove();
store.lastUpdated = new Date();
return store.pills.splice(idx, 1);
var pill = store.pills.splice(idx, 1);
if (typeof store.removePillFunction === "function") {
store.removePillFunction(pill);
}
return pill;
}
},
@ -147,6 +152,9 @@ var input_pill = function ($parent) {
if (pill) {
pill.$element.remove();
if (typeof store.removePillFunction === "function") {
store.removePillFunction(pill);
}
}
},
@ -319,6 +327,10 @@ var input_pill = function ($parent) {
store.getKeyFunction = callback;
},
onPillRemove: function (callback) {
store.removePillFunction = callback;
},
validate: function (callback) {
store.validation = callback;
},