From 511f2f3db4c593ba4e523894af37dead1532cb60 Mon Sep 17 00:00:00 2001 From: Brock Whittaker Date: Mon, 18 Dec 2017 10:36:00 -0800 Subject: [PATCH] input-pill: Add "onPillRemove" callback. This will now allow a callback to be triggered when a pill is removed from the set. --- static/js/input_pill.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/static/js/input_pill.js b/static/js/input_pill.js index eed21fa359..93f0b99e1d 100644 --- a/static/js/input_pill.js +++ b/static/js/input_pill.js @@ -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; },