angular-bootstrap-multiselect
angular-bootstrap-multiselect copied to clipboard
Enter button to add custom value to selected
Please add selectedoptions and unselectedoptions to scope so it will be easy to add data from input to selected. Thank you
// Assuming you have a data structure to store selected options
data() {
return {
selectedOptions: [],
unselectedOptions: [],
customInput: '', // Input for adding custom values
};
},
methods: {
// Function to handle adding custom values to selected options
addCustomValue() {
if (this.customInput.trim() !== '') {
this.selectedOptions.push(this.customInput.trim());
this.customInput = ''; // Clear the input field
}
},
// Function to handle removing selected options
removeSelectedOption(index) {
this.selectedOptions.splice(index, 1);
},
// Function to handle keypress event (Enter key)
handleKeyPress(event) {
if (event.key === 'Enter') {
this.addCustomValue();
}
},
},