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
1f6c45e0
Commit
1f6c45e0
authored
Aug 07, 2014
by
David Stutz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#358.
parent
1d6dc331
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
1 deletion
+68
-1
index.html
index.html
+47
-1
bootstrap-multiselect.js
js/bootstrap-multiselect.js
+21
-0
No files found.
index.html
View file @
1f6c45e0
...
...
@@ -224,6 +224,20 @@ $(document).ready(function() {
});
$
(
'
#example48
'
).
multiselect
();
$
(
'
#example51
'
).
multiselect
({
disableIfEmpty
:
true
});
$
(
'
#example51-rebuild
'
).
on
(
'
click
'
,
function
()
{
$
(
'
#example51
'
).
multiselect
(
'
rebuild
'
);
});
$
(
'
#example51-add
'
).
on
(
'
click
'
,
function
()
{
$
(
'
#example51
'
).
append
(
'
<option value="cheese">Cheese</option><option value="tomato">Tomato</option>
'
);
});
$
(
'
#example51-delete
'
).
on
(
'
click
'
,
function
()
{
$
(
'
option[value="cheese"]
'
,
$
(
'
#example51
'
)).
remove
();
$
(
'
option[value="tomato"]
'
,
$
(
'
#example51
'
)).
remove
();
});
});
</script>
...
...
@@ -242,7 +256,7 @@ $(document).ready(function() {
<option
value=
"onions"
>
Onions
</option>
</select>
</td>
<td>
<td
width=
"50%"
>
Normal select. The plugin will do single selection using radio buttons rather than multiple selection using checkboxes.
</td>
</tr>
...
...
@@ -612,6 +626,21 @@ $(document).ready(function() {
Use the
<code>
checkboxName
</code>
to adapt the
<code>
name
</code>
attribute of the used checkboxes.
</td>
</tr>
<tr>
<td>
<div
class=
"btn-group"
>
<select
id=
"example51"
multiple=
"multiple"
></select>
<button
id=
"example51-add"
class=
"btn btn-default"
>
Add options
</button>
<button
id=
"example51-delete"
class=
"btn btn-default"
>
Delete options
</button>
<button
id=
"example51-rebuild"
class=
"btn btn-primary"
>
Rebuild
</button>
</div>
</td>
<td>
<p>
Automatically disable multiselect if it has no options.
</p>
</td>
</tr>
</table>
<div
class=
"page-header"
>
...
...
@@ -1082,6 +1111,23 @@ $(document).ready(function() {
dropRight: true
});
});
<
/script
>
</pre>
</td>
</tr>
<tr>
<td><code>
disableEmpty
</code></td>
<td>
Set to
<code>
true
</code>
to disable the select if no options are available.
</td>
<td>
<pre
class=
"prettyprint linenums"
>
<
script type=
"
text/javascript
">
$(document).ready(function() {
$(
'
.multiselect
'
).multiselect({
disableEmpty: true
});
});
<
/script
>
</pre>
</td>
...
...
js/bootstrap-multiselect.js
View file @
1f6c45e0
...
...
@@ -118,6 +118,10 @@
this
.
updateButtonText
();
this
.
updateSelectAll
();
if
(
this
.
options
.
disableIfEmpty
)
{
this
.
disableIfEmpty
();
}
this
.
$select
.
hide
().
after
(
this
.
$container
);
};
...
...
@@ -242,6 +246,7 @@
nonSelectedText
:
'
None selected
'
,
nSelectedText
:
'
selected
'
,
numberDisplayed
:
3
,
disableIfEmpty
:
false
,
templates
:
{
button
:
'
<button type="button" class="multiselect dropdown-toggle" data-toggle="dropdown"></button>
'
,
ul
:
'
<ul class="multiselect-container dropdown-menu"></ul>
'
,
...
...
@@ -913,6 +918,10 @@
this
.
updateButtonText
();
this
.
updateSelectAll
();
if
(
this
.
options
.
disableIfEmpty
)
{
this
.
disableIfEmpty
();
}
if
(
this
.
options
.
dropRight
)
{
this
.
$ul
.
addClass
(
'
pull-right
'
);
}
...
...
@@ -965,6 +974,18 @@
.
addClass
(
'
disabled
'
);
},
/**
* Disable the multiselect if there are no options in the select.
*/
disableIfEmpty
:
function
()
{
if
(
$
(
'
option
'
,
this
.
$select
).
length
<=
0
)
{
this
.
disable
();
}
else
{
this
.
enable
();
}
},
/**
* Set the options.
*
...
...
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