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

updateSelectValue multiple issue #61

Open
afonja14755 opened this issue Jul 10, 2023 · 2 comments
Open

updateSelectValue multiple issue #61

afonja14755 opened this issue Jul 10, 2023 · 2 comments

Comments

@afonja14755
Copy link

afonja14755 commented Jul 10, 2023

When user check and uncheck item, in native select, option doesn't remove attribute selected=true.

You can fix it by:

var select = this.el;
select.querySelectorAll("option").forEach(function (item) {
  item.removeAttribute("selected");
});
this.selectedOptions.forEach(function(item) {
  var el = select.querySelector(`option[value="${item.data.value}"]`);
  if (el){
    //Change it, cause it works more correctly.
    el.setAttribute("selected", "selected");
    el.selected = true;
  }
});

Or some better solution with indexOf, filter.

@gpham99
Copy link

gpham99 commented Mar 28, 2024

+1 on this. This would be so nice

@afonja14755
Copy link
Author

afonja14755 commented Apr 9, 2024

+1 on this. This would be so nice

If you are looking for a new and supported library for selectors in native JavaScript, I can recommend you my own, which I am following.

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