knockout.viewmodel
knockout.viewmodel copied to clipboard
toModel excluding computed observables
When using a viewModel with computed observables, updatingFromModel works fine, but when mapping back to the model, using toModel, ko.viewmodel omits all computed observables.
When using ko is usual that some extenders replace the current observable with a computed one, so in that case ko.viewmodel becomes unusable.
It appears to be a explicit filter on the recrusiveTo function, excluding all the computed observables:
if (!ko.isComputed(child) && !((temp = unwrap(child)) && temp.constructor === Function)) {
recursiveResult = recrusiveTo(child, {
name: p,
parent: (context.name === "[i]" ? context.parent : context.name) + "." + p,
full: context.full + "." + p
});
//if badResult wasn't returned then add property
if (recursiveResult !== badResult) {
result[p] = recursiveResult;
}
}
I did eliminated that filter and now is working as expected.
if (!((temp = unwrap(child)) && temp.constructor === Function)) {
Can I submit the change?
Agreed! Must apply patch
Is this applied? This plugin is unusable if not. Nuget seems to still have old version.