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
3f1b6be7
Commit
3f1b6be7
authored
Jan 02, 2015
by
Aaron-P
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if other bindings exist before trying to attach
parent
6dabdcbf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
36 deletions
+42
-36
bootstrap-multiselect.js
dist/js/bootstrap-multiselect.js
+42
-36
No files found.
dist/js/bootstrap-multiselect.js
View file @
3f1b6be7
...
...
@@ -19,51 +19,57 @@
$element
.
multiselect
(
config
);
var
options
=
allBindings
.
get
(
'
options
'
);
if
(
ko
.
isObservable
(
options
))
{
ko
.
computed
({
read
:
function
()
{
options
();
setTimeout
(
function
()
{
var
ms
=
$element
.
data
(
'
multiselect
'
);
if
(
ms
)
ms
.
updateOriginalOptions
();
//Not sure how beneficial this is.
$element
.
multiselect
(
'
rebuild
'
);
},
1
);
},
disposeWhenNodeIsRemoved
:
element
});
if
(
allBindings
.
has
(
'
options
'
))
{
var
options
=
allBindings
.
get
(
'
options
'
);
if
(
ko
.
isObservable
(
options
))
{
ko
.
computed
({
read
:
function
()
{
options
();
setTimeout
(
function
()
{
var
ms
=
$element
.
data
(
'
multiselect
'
);
if
(
ms
)
ms
.
updateOriginalOptions
();
//Not sure how beneficial this is.
$element
.
multiselect
(
'
rebuild
'
);
},
1
);
},
disposeWhenNodeIsRemoved
:
element
});
}
}
//value and selectedOptions are two-way, so these will be triggered even by our own actions.
//It needs some way to tell if they are triggered because of us or because of outside change.
//It doesn't loop but it's a waste of processing.
var
value
=
allBindings
.
get
(
'
value
'
);
if
(
ko
.
isObservable
(
value
))
{
ko
.
computed
({
read
:
function
()
{
value
();
setTimeout
(
function
()
{
$element
.
multiselect
(
'
refresh
'
);
},
1
);
},
disposeWhenNodeIsRemoved
:
element
}).
extend
({
rateLimit
:
100
,
notifyWhenChangesStop
:
true
});
if
(
allBindings
.
has
(
'
value
'
))
{
var
value
=
allBindings
.
get
(
'
value
'
);
if
(
ko
.
isObservable
(
value
))
{
ko
.
computed
({
read
:
function
()
{
value
();
setTimeout
(
function
()
{
$element
.
multiselect
(
'
refresh
'
);
},
1
);
},
disposeWhenNodeIsRemoved
:
element
}).
extend
({
rateLimit
:
100
,
notifyWhenChangesStop
:
true
});
}
}
//Switched from arrayChange subscription to general subscription using 'refresh'.
//Not sure performance is any better using 'select' and 'deselect'.
var
selectedOptions
=
allBindings
.
get
(
'
selectedOptions
'
);
if
(
ko
.
isObservable
(
selectedOptions
))
{
ko
.
computed
({
read
:
function
()
{
selectedOptions
();
setTimeout
(
function
()
{
$element
.
multiselect
(
'
refresh
'
);
},
1
);
},
disposeWhenNodeIsRemoved
:
element
}).
extend
({
rateLimit
:
100
,
notifyWhenChangesStop
:
true
});
if
(
allBindings
.
has
(
'
selectedOptions
'
))
{
var
selectedOptions
=
allBindings
.
get
(
'
selectedOptions
'
);
if
(
ko
.
isObservable
(
selectedOptions
))
{
ko
.
computed
({
read
:
function
()
{
selectedOptions
();
setTimeout
(
function
()
{
$element
.
multiselect
(
'
refresh
'
);
},
1
);
},
disposeWhenNodeIsRemoved
:
element
}).
extend
({
rateLimit
:
100
,
notifyWhenChangesStop
:
true
});
}
}
ko
.
utils
.
domNodeDisposal
.
addDisposeCallback
(
element
,
function
()
{
...
...
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