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

Clickable Optgroup headers #305

Closed
wants to merge 1 commit into from
Closed

Conversation

tkivari
Copy link

@tkivari tkivari commented May 14, 2014

Adds clickable optGroup headers that allow a user to select or deselect all of the options in an optgroup. For multiselect dropdowns.

…to select or deselect the all options in the group
@philfreo
Copy link
Contributor

see also #233 which has a similar implemenation

@svrin
Copy link

svrin commented May 23, 2014

Thx for having this feature now, but I think that there should be a better way than creating phony random ids and probably running in name clashes like storing the reference or index.

@davidstutz
Copy link
Owner

For reference: #388 is similar and I will try to merge #388.

@davidstutz davidstutz closed this Oct 13, 2014
davidstutz added a commit that referenced this pull request Oct 13, 2014
#305, #302. Added enableClickableOptGroups option.
@markusd1984
Copy link

markusd1984 commented Dec 1, 2022

I've added another similar setting enableClickableOptGroupsSingle: false, to allow for clickable headers for single select which is much easier to click than the carret on the very right. https://github.com/davidstutz/bootstrap-multiselect/pull/388

if (this.options.enableClickableOptGroupsSingle) {
                $groupOption.addClass("multiselect-group-header");
                $groupOption.html(" " + label);
            }
if (this.options.enableClickableOptGroupsSingle /*&& this.options.multiple*/) {
                $(".multiselect-group-header", this.$popupContainer).off("click");
                $(".multiselect-group-header", this.$popupContainer).on("click", $.proxy(function (event) {
                    var $group = $(event.target).closest('.multiselect-group');
                    var $inputs = $group.nextUntil(".multiselect-group")
                        .not('.multiselect-filter-hidden');

                    var visible = true;
                    $inputs.each(function () {
                        visible = visible && !$(this).hasClass('multiselect-collapsible-hidden');
                    });

                    if (visible) {
                        $inputs.hide()
                            .addClass('multiselect-collapsible-hidden');
                    }
                    else {
                        $inputs.show()
                            .removeClass('multiselect-collapsible-hidden');
                    }
                }, this));
            }

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

Successfully merging this pull request may close these issues.

None yet

5 participants