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
6dabdcbf
Commit
6dabdcbf
authored
Dec 03, 2014
by
Aaron-P
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Destroy computeds when element is destroyed
parent
db4d64e9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
22 deletions
+31
-22
bootstrap-multiselect.js
dist/js/bootstrap-multiselect.js
+31
-22
No files found.
dist/js/bootstrap-multiselect.js
View file @
6dabdcbf
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
ko
.
bindingHandlers
.
multiselect
=
{
ko
.
bindingHandlers
.
multiselect
=
{
after
:
[
'
options
'
,
'
value
'
,
'
selectedOptions
'
],
after
:
[
'
options
'
,
'
value
'
,
'
selectedOptions
'
],
init
:
function
(
element
,
valueAccessor
,
allBindings
,
viewModel
,
bindingContext
)
{
init
:
function
(
element
,
valueAccessor
,
allBindings
,
viewModel
,
bindingContext
)
{
var
$element
=
$
(
element
);
var
$element
=
$
(
element
);
var
config
=
ko
.
toJS
(
valueAccessor
());
var
config
=
ko
.
toJS
(
valueAccessor
());
...
@@ -21,14 +21,17 @@
...
@@ -21,14 +21,17 @@
var
options
=
allBindings
.
get
(
'
options
'
);
var
options
=
allBindings
.
get
(
'
options
'
);
if
(
ko
.
isObservable
(
options
))
{
if
(
ko
.
isObservable
(
options
))
{
ko
.
computed
(
function
()
{
ko
.
computed
({
read
:
function
()
{
options
();
options
();
setTimeout
(
function
()
{
setTimeout
(
function
()
{
var
ms
=
$element
.
data
(
'
multiselect
'
);
var
ms
=
$element
.
data
(
'
multiselect
'
);
if
(
ms
)
if
(
ms
)
ms
.
updateOriginalOptions
();
//Not sure how beneficial this is.
ms
.
updateOriginalOptions
();
//Not sure how beneficial this is.
$element
.
multiselect
(
'
rebuild
'
);
$element
.
multiselect
(
'
rebuild
'
);
},
1
);
},
1
);
},
disposeWhenNodeIsRemoved
:
element
});
});
}
}
...
@@ -37,32 +40,38 @@
...
@@ -37,32 +40,38 @@
//It doesn't loop but it's a waste of processing.
//It doesn't loop but it's a waste of processing.
var
value
=
allBindings
.
get
(
'
value
'
);
var
value
=
allBindings
.
get
(
'
value
'
);
if
(
ko
.
isObservable
(
value
))
{
if
(
ko
.
isObservable
(
value
))
{
ko
.
computed
(
function
()
{
ko
.
computed
({
read
:
function
()
{
value
();
value
();
setTimeout
(
function
()
{
setTimeout
(
function
()
{
$element
.
multiselect
(
'
refresh
'
);
$element
.
multiselect
(
'
refresh
'
);
},
1
);
},
1
);
}).
extend
(
{
rateLimit
:
100
,
notifyWhenChangesStop
:
true
});
},
disposeWhenNodeIsRemoved
:
element
}).
extend
({
rateLimit
:
100
,
notifyWhenChangesStop
:
true
});
}
}
//Switched from arrayChange subscription to general subscription using 'refresh'.
//Switched from arrayChange subscription to general subscription using 'refresh'.
//Not sure performance is any better using 'select' and 'deselect'.
//Not sure performance is any better using 'select' and 'deselect'.
var
selectedOptions
=
allBindings
.
get
(
'
selectedOptions
'
);
var
selectedOptions
=
allBindings
.
get
(
'
selectedOptions
'
);
if
(
ko
.
isObservable
(
selectedOptions
))
{
if
(
ko
.
isObservable
(
selectedOptions
))
{
ko
.
computed
(
function
()
{
ko
.
computed
({
read
:
function
()
{
selectedOptions
();
selectedOptions
();
setTimeout
(
function
()
{
setTimeout
(
function
()
{
$element
.
multiselect
(
'
refresh
'
);
$element
.
multiselect
(
'
refresh
'
);
},
1
);
},
1
);
},
disposeWhenNodeIsRemoved
:
element
}).
extend
({
rateLimit
:
100
,
notifyWhenChangesStop
:
true
});
}).
extend
({
rateLimit
:
100
,
notifyWhenChangesStop
:
true
});
}
}
ko
.
utils
.
domNodeDisposal
.
addDisposeCallback
(
element
,
function
()
{
ko
.
utils
.
domNodeDisposal
.
addDisposeCallback
(
element
,
function
()
{
$element
.
multiselect
(
'
destroy
'
);
$element
.
multiselect
(
'
destroy
'
);
});
});
},
},
update
:
function
(
element
,
valueAccessor
,
allBindings
,
viewModel
,
bindingContext
)
{
update
:
function
(
element
,
valueAccessor
,
allBindings
,
viewModel
,
bindingContext
)
{
var
$element
=
$
(
element
);
var
$element
=
$
(
element
);
var
config
=
ko
.
toJS
(
valueAccessor
());
var
config
=
ko
.
toJS
(
valueAccessor
());
...
...
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