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 to select all options on load? #8

Open
mzhadigerov opened this issue Apr 17, 2023 · 1 comment
Open

How to select all options on load? #8

mzhadigerov opened this issue Apr 17, 2023 · 1 comment

Comments

@mzhadigerov
Copy link

mzhadigerov commented Apr 17, 2023

Hi! Thanks for the wonderfull repo. I'm loading the options on page load and was wondering how can I select the "all" option (select all options) on page load?

Did try this, but it seems not working:

var selectElement = document.getElementById('select-options')
var multiselectAllSelector = document.getElementsByClassName("multiselect-dropdown-all-selector")[0]
multiselectAllSelector.classList.add("checked")
selectElement.loadOptions()
@kriegschrei
Copy link

kriegschrei commented Nov 1, 2023

Here's how I solved this. The checkboxes have listeners for click events on them.

// send a click to the "all" button to trigger the event listener
document.getElementById('select-options').parentNode.getElementsByClassName('multiselect-dropdown-all-selector')[0].click();
// send a click somewhere else to collapse the drop-down
document.getElementById('foo').click();

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