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
8ec7d721
Commit
8ec7d721
authored
Oct 14, 2015
by
David Stutz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Example for #553 and #548.
parent
9abf0138
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
18 deletions
+90
-18
bootstrap-multiselect.js
dist/js/bootstrap-multiselect.js
+18
-18
index.html
index.html
+72
-0
No files found.
dist/js/bootstrap-multiselect.js
View file @
8ec7d721
...
...
@@ -937,46 +937,46 @@
*/
refresh
:
function
()
{
var
inputs
=
$
.
map
(
$
(
'
li input
'
,
this
.
$ul
),
$
);
var
selectedClass
=
this
.
options
.
selectedClass
;
$
(
'
option
'
,
this
.
$select
).
each
(
function
(
index
,
element
)
{
$
(
'
option
'
,
this
.
$select
).
each
(
$
.
proxy
(
function
(
index
,
element
)
{
var
$elem
=
$
(
element
);
var
value
=
$elem
.
val
();
var
$input
;
for
(
var
i
=
inputs
.
length
;
0
<
i
--
;
/**/
)
{
for
(
var
i
=
inputs
.
length
;
0
<
i
--
;
/**/
)
{
if
(
value
!==
(
$input
=
inputs
[
i
]).
val
())
continue
;
// wrong li
if
(
$elem
.
is
(
'
:selected
'
))
{
if
(
$elem
.
is
(
'
:selected
'
))
{
$input
.
prop
(
'
checked
'
,
true
);
if
(
selectedClass
)
{
if
(
this
.
options
.
selectedClass
)
{
$input
.
closest
(
'
li
'
)
.
addClass
(
selectedClass
);
}
.
addClass
(
this
.
options
.
selectedClass
);
}
}
else
{
else
{
$input
.
prop
(
'
checked
'
,
false
);
if
(
selectedClass
)
{
if
(
this
.
options
.
selectedClass
)
{
$input
.
closest
(
'
li
'
)
.
removeClass
(
selectedClass
);
}
.
removeClass
(
this
.
options
.
selectedClass
);
}
}
if
(
$elem
.
is
(
"
:disabled
"
))
{
if
(
$elem
.
is
(
"
:disabled
"
))
{
$input
.
attr
(
'
disabled
'
,
'
disabled
'
)
.
prop
(
'
disabled
'
,
true
)
.
closest
(
'
li
'
)
.
addClass
(
'
disabled
'
);
.
addClass
(
'
disabled
'
);
}
else
{
else
{
$input
.
prop
(
'
disabled
'
,
false
)
.
closest
(
'
li
'
)
.
removeClass
(
'
disabled
'
);
}
break
;
// assumes unique values
.
removeClass
(
'
disabled
'
);
}
break
;
// assumes unique values
}
});
}
,
this
)
);
this
.
updateButtonText
();
this
.
updateSelectAll
();
...
...
index.html
View file @
8ec7d721
...
...
@@ -4322,6 +4322,78 @@ $(document).ready(function() {
<
select id=
"
example-disable-javascript
"
multiple=
"
multiple
"><
/select
>
</pre>
<p>
Performance example for using
<code>
.multiselect('refresh')
</code>
with a large number of options:
</p>
<p
class=
"alert alert-warning"
>
The below examples need to be activated.
<b>
Note that this may take some time!
</b></p>
<p
class=
"alert alert-info"
><button
id=
"example-large-refresh-button"
class=
"btn btn-primary"
>
Activate
</button></p>
<div
class=
"example"
>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
'
#example-large-refresh-button
'
).
on
(
'
click
'
,
function
()
{
for
(
var
i
=
0
;
i
<
1000
;
i
++
)
{
$
(
'
#example-large-refresh
'
).
append
(
'
<option value="
'
+
i
+
'
">Option
'
+
i
+
'
</option>
'
);
}
$
(
'
#example-large-refresh
'
).
multiselect
();
});
$
(
'
#example-large-refresh-refresh
'
).
on
(
'
click
'
,
function
()
{
$
(
'
#example-large-refresh
'
).
multiselect
(
'
refresh
'
);
});
$
(
'
#example-large-refresh-select
'
).
on
(
'
click
'
,
function
()
{
var
count
=
0
;
$
(
'
#example-large-refresh option
'
).
each
(
function
()
{
var
i
=
$
(
this
).
val
();
if
(
i
%
2
==
0
)
{
$
(
this
).
prop
(
'
selected
'
,
true
);
count
++
;
}
});
alert
(
'
Selected
'
+
count
+
'
options!
'
);
});
});
</script>
<div
class=
"btn-group"
>
<select
id=
"example-large-refresh"
multiple=
"multiple"
>
</select>
<button
id=
"example-large-refresh-select"
class=
"btn btn-default"
>
Select every second option ...
</button>
<button
id=
"example-large-refresh-refresh"
class=
"btn btn-primary"
>
Refresh!
</button>
</div>
</div>
<div
class=
"highlight"
>
<pre
class=
"prettyprint linenums"
>
<
script type=
"
text/javascript
">
$(document).ready(function() {
$('#example-confirmation').multiselect({
onChange: function(element, checked) {
if(checked === true) {
//action taken here if true
}
else if(checked === false) {
if(confirm('Do you wish to deselect the element?')) {
//action taken here
}
else {
$("#example-confirmation").multiselect('select', element.val());
}
}
}
});
});
<
/script
>
</pre>
</div>
<div
class=
"page-header"
>
<h2
id=
"post"
>
Server-Side Processing
</h2>
</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