Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap-multiselect
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bootstrap-multiselect
Commits
13007b08
Commit
13007b08
authored
Apr 19, 2016
by
David Stutz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forgot text and code example for new example.
parent
3665c689
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
index.html
index.html
+64
-0
No files found.
index.html
View file @
13007b08
...
@@ -5413,6 +5413,10 @@ $(document).ready(function() {
...
@@ -5413,6 +5413,10 @@ $(document).ready(function() {
</pre>
</pre>
</div>
</div>
<p>
The below example demonstrates how to show the
<code>
optgroup
</code>
's label if all
<code>
option
</code>
's within this group are selected:
</p>
<div
class=
"example"
>
<div
class=
"example"
>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
...
@@ -5478,7 +5482,67 @@ $(document).ready(function() {
...
@@ -5478,7 +5482,67 @@ $(document).ready(function() {
</div>
</div>
<div
class=
"highlight"
>
<div
class=
"highlight"
>
<pre
class=
"prettyprint linenums"
>
<pre
class=
"prettyprint linenums"
>
<
script type=
"
text/javascript
">
$(document).ready(function() {
$('#example-optgroup-buttonText').multiselect({
buttonText: function(options, select) {
// First consider the simple cases, i.e. disabled and empty.
if (this.disabledText.length
>
0
&&
(this.disableIfEmpty || select.prop('disabled'))
&&
options.length == 0) {
return this.disabledText;
}
else if (options.length === 0) {
return this.nonSelectedText;
}
var $select = $(select);
var $optgroups = $('optgroup', $select);
var delimiter = this.delimiterText;
var text = '';
// Go through groups.
$optgroups.each(function() {
var $selectedOptions = $('option:selected', this);
var $options = $('option', this);
if ($selectedOptions.length == $options.length) {
text += $(this).attr('label') + delimiter;
}
else {
$selectedOptions.each(function() {
text += $(this).text() + delimiter;
});
}
});
var $remainingOptions = $('option:selected', $select).not('optgroup option');
$remainingOptions.each(function() {
text += $(this).text() + delimiter;
});
return text.substr(0, text.length - 2);
}
});
});
<
/script
>
<
div class=
"
btn-group
">
<
select id=
"
example-optgroup-buttonText
"
multiple=
"
multiple
">
<
optgroup class=
"
group-1
"
label=
"
Group 1
">
<
option value=
"
1-1
">
Option 1.1
<
/option
>
<
option value=
"
1-2
">
Option 1.2
<
/option
>
<
option value=
"
1-3
">
Option 1.3
<
/option
>
<
/optgroup
>
<
optgroup class=
"
group-2
"
label=
"
Group 2
">
<
option value=
"
2-1
">
Option 2.1
<
/option
>
<
option value=
"
2-2
">
Option 2.2
<
/option
>
<
option value=
"
2-3
">
Option 2.3
<
/option
>
<
/optgroup
>
<
/select
>
<
/div
>
</pre>
</pre>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment