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
ae6405b7
Commit
ae6405b7
authored
Apr 26, 2013
by
Luís Rudge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
smaller examples
parent
6b366253
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
9 deletions
+8
-9
README.md
README.md
+1
-1
knockout-examples.html
knockout-examples.html
+7
-8
No files found.
README.md
View file @
ae6405b7
...
...
@@ -273,7 +273,7 @@ Thanks to [Devristo](https://github.com/Devristo) and [Luis Rudge](https://githu
Note the multiselect: true binding!
<select
class="multiSelect" data-bind="options: items, optionsText: 'text', optionsValue: 'id',selectedOptions: selectedItems, multiselect: multiSelectInitOptions" multiple="multiple
"></select>
<select
multiple="multiple" data-bind="options: items, selectedOptions: selectedItems, multiselect: multiSelectInitOptions
"></select>
**Apply Knockout view model**
...
...
knockout-examples.html
View file @
ae6405b7
...
...
@@ -47,8 +47,7 @@
</tr>
<tr>
<td>
<select
multiple=
"multiple"
data-bind=
"options: items, optionsText: 'text', optionsValue: 'id',selectedOptions: selectedItems, multiselect: multiSelectInitOptions"
>
</select>
<select
multiple=
"multiple"
data-bind=
"options: items, selectedOptions: selectedItems, multiselect: multiSelectInitOptions"
></select>
</td>
<td><span
data-bind=
"text: ko.toJSON(selectedItems())"
/></td>
<td>
Basic knockout multiselect example with select all options enabled. Notice that once an item is added to the collection, the select all option isn't checked anymore because it isn't true anymore.
...
...
@@ -69,11 +68,11 @@
var
viewModel
=
function
()
{
var
self
=
this
;
self
.
items
=
ko
.
observableArray
([
{
id
:
1
,
text
:
'
Cheese
'
}
,
{
id
:
2
,
text
:
'
Tomatoes
'
}
,
{
id
:
3
,
text
:
'
Mozzarella
'
}
,
{
id
:
4
,
text
:
'
Mushrooms
'
}
,
{
id
:
5
,
text
:
'
Pepperoni
'
}
'
Cheese
'
,
'
Tomatoes
'
,
'
Mozzarella
'
,
'
Mushrooms
'
,
'
Pepperoni
'
]);
self
.
multiSelectInitOptions
=
{
...
...
@@ -84,7 +83,7 @@
self
.
selectedItems
=
ko
.
observableArray
([]);
self
.
addItem
=
function
()
{
self
.
items
.
push
(
{
id
:
(
self
.
items
().
length
+
1
),
text
:
'
new item
'
+
(
self
.
items
().
length
+
1
)}
);
self
.
items
.
push
(
'
new item
'
+
(
self
.
items
().
length
+
1
)
);
};
return
self
;
...
...
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