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

An option to display optgroups names instead of list of options in the title #29

Closed
smartcorestudio opened this issue Nov 21, 2013 · 4 comments

Comments

@smartcorestudio
Copy link

I think that it also can be useful to have an option to display optgroup names instead of list of options in the title, when the whole groups were selected.
For example we can turn this:
2013-11-21 10_48_52-multiple select
into this
[Group1], [Group3]
instead of "Option1, Option2, Option3, Option7, Option..."
Optionally, it also can be displayed in the following way:
[Group1: Option1, Option2], [Group3: Option7]

@wenzhixin
Copy link
Owner

@smartcorestudio
Copy link
Author

WOW!!!

@AllanPooley
Copy link

@wenzhixin

Is it possible to disable this notation and use the original in your current release of multi-select?

@AllanPooley
Copy link

AllanPooley commented Mar 5, 2018

For anyone looking to have their selections appear as:

Option 1, Option 2, Option 3

As opposed to:

[Group1: Option1, Option2], [Group3: Option3]

You can change the following code (Line 560 to 570):

html.push('[');
html.push(text);
if ($children.length > $selected.length) {
    var list = [];
    $selected.each(function () {
        list.push($(this).parent().text());
    });
    html.push(': ' + list.join(', '));
}
html.push(']');
texts.push(html.join(''));

To:

// Modified to not include option groups in selected items text
var list = [];
$selected.each(function () {
    list.push($(this).parent().text().trim());
});
html.push(list.join(', '));
texts.push(html.join(''));

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

3 participants