angular-bootstrap-multiselect icon indicating copy to clipboard operation
angular-bootstrap-multiselect copied to clipboard

Enter button to add custom value to selected

Open Dacheng-Zhao-activehealth opened this issue 8 years ago • 1 comments

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();
    }
  },
},

ljluestc avatar Nov 12 '23 22:11 ljluestc