I use Breeze in my asp.net mvc project.
I defined the following computed function:
var isDetached = ko.computed(function () {
if (rolling())
return rolling().entityAspect.entityState.isDetached();
});
An entity is detached
(for example) when it is first added and then (immediately) cancelled.
Basic scenario:
- (1) create a new 'rolling'
- >> the entityState is 'Added'
- (2) cancel the operation of creation (datacontext.cancelChanges)
- >> the entityState is 'Detached'
The problem: when trying to get the value of entityState.isDetached()
from my computed knockout observable, the value doesn't seems to be dynamic. From the previous basic scenario, after step 1, the ko.computed isDetached()
is false (because it is Added). After step 2, the ko.computed is still false but it should be true.
It works if I explicitly get the value like this:
if (rolling().entityAspect.entityState.isDetached())
...
Any idea why my ko.computed is not dynamic?
Thanks.