diff --git a/app/assets/javascripts/sitewide/dropdown_selector.js b/app/assets/javascripts/sitewide/dropdown_selector.js index ba7eefb6f..1ff4bf572 100644 --- a/app/assets/javascripts/sitewide/dropdown_selector.js +++ b/app/assets/javascripts/sitewide/dropdown_selector.js @@ -708,6 +708,7 @@ var dropdownSelector = (function() { } else { // Or delete specific one deleteValue(selector, container, tagLabel.data('ds-tag-id'), tagLabel.data('ds-tag-group')); + removeOptionFromSelector(selector, tagLabel.data('ds-tag-id')); } }, 350); } @@ -871,6 +872,19 @@ var dropdownSelector = (function() { return result; } + function appendOptionToSelector(selector, value) { + $(selector).append( + `` + ); + } + + function removeOptionFromSelector(selector, id) { + $(selector).find(`option[value="${id}"]`).remove(); + } + // //////////////////// // Public functions /// // //////////////////// @@ -987,6 +1001,7 @@ var dropdownSelector = (function() { currentData = getCurrentData($(selector).next()); currentData.push(value); setData($(selector), currentData, skip_event); + appendOptionToSelector(selector, value); return this; },