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

"Select All" on each sub-group (optgroup) #213

Open
gonzalo-massa opened this issue Jun 26, 2017 · 6 comments
Open

"Select All" on each sub-group (optgroup) #213

gonzalo-massa opened this issue Jun 26, 2017 · 6 comments

Comments

@gonzalo-massa
Copy link

Hi,
Is there an easy way to add the same behavior of the "Select all" inside each group? I've been looking at the source code and I'm not sure how much of the current code will I be able to reuse.

Can you give me a hint on how to reach a solution?

Thank you!

@jsvnadmin
Copy link

Hi,
Can you add select all feature to optgroup at next version?

Thank you!

@Zenoo
Copy link
Collaborator

Zenoo commented Jun 20, 2021

This isn't possible with the current version.
Please upvote the issue if you would want this feature.
I'll get around to it once I resolve all current issues.

@mbardelmeijer
Copy link
Contributor

This would be awesome to have, 👍 from us.

@Zenoo
Copy link
Collaborator

Zenoo commented Aug 4, 2021

Feel free to open a PR for this, if you feel like it, I don't have the time to handle it right now. 🚀

@mbardelmeijer
Copy link
Contributor

Haha yeah same here. Happy to support sponsored development for it though.

@williamtworth
Copy link

williamtworth commented Jul 12, 2022

If it helps anyone, I have achieved the desired functionality using the following method:

const ss = $("select");
ss.SumoSelect();

    ss.parent().find("li.group").on("click", function (e) {

        if (e.target) {
            if($(e.target).parents("li:first").hasClass("opt")){
                return;
            }
        }

        if ($(this).hasClass("g-selected")) {
            $(this).find(".opt.selected").each(function () {
                $(this).find("span").trigger("click");
            });
        } else {
            $(this).find(".opt:not(.selected)").each(function () {
                $(this).find("span").trigger("click");
            });
        }
        $(this).toggleClass("g-selected");

    });

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

No branches or pull requests

5 participants