Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enter button to add custom value to selected #35

Open
Dacheng-Zhao-activehealth opened this issue Mar 20, 2017 · 1 comment
Open

Enter button to add custom value to selected #35

Dacheng-Zhao-activehealth opened this issue Mar 20, 2017 · 1 comment

Comments

@Dacheng-Zhao-activehealth

Please add selectedoptions and unselectedoptions to scope so it will be easy to add data from input to selected. Thank you

@ljluestc
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants