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

How do I can get selected and removed value? #5

Open
melashu opened this issue May 2, 2024 · 1 comment
Open

How do I can get selected and removed value? #5

melashu opened this issue May 2, 2024 · 1 comment

Comments

@melashu
Copy link

melashu commented May 2, 2024

hey @BakiVernes, thans for your contribution

I was trying to use this awesome library in my app, but am confused how can I get the selected value. In this page, it is described as we can user multiselect-change but am not sure how can I use it, can you please give a hint?

thanks

@melashu
Copy link
Author

melashu commented May 2, 2024

If it help someone in the future here is how I useed it

   <div data-controller="multiselect"  data-action="multiselect-added->payment-session#getItem multiselect-removed->payment-session#removeItem" data-multiselect-selected-value='[{ "value": "failed", "text": "Failed"}]' data-multiselect-items-value='[{ "value": "failed", "text": "Failed"}, { "value": "open", "text": "Open"}, { "value": "paid", "text": "Paid"}]' data-placeholder="Search for state">
      <select multiple="multiple" class="multiselect__hidden filter-date-field rounded-r-none border-r-0"  data-multiselect-target="hidden" name="form[test_ids][]" id="form_test_ids"></select>
    </div>

payment-session is my custom stimulus controller, inside it event handler looks like below

  removeItem(e) {
    const value = e.detail.id
    console.log(this.items)
  }

  getItem(e) {
    const value = e.detail.item.value
    console.log(value)
   }

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

1 participant