Double-click to remove in Settings lists

This commit is contained in:
jokob-sk
2024-04-23 22:57:24 +10:00
parent f600398353
commit a8fad6ac74
4 changed files with 57 additions and 6 deletions

View File

@@ -175,9 +175,26 @@
} else {
return false;
}
}
// -------------------------------------------------------------------
// Function to remove an item from the select element
function removeOptionItem(option) {
option.remove();
}
// -------------------------------------------------------------------
// Function to initialize remove functionality on select options
function initRemoveBtnOptn(selectorId) {
// Attach double-click event listeners to "Remove"
$(`#${selectorId} option`).addClass('removable-option').on('dblclick', function() {
const $option = $(this);
removeOptionItem($option);
});
}