Skip to content

Commit a7f4b56

Browse files
committed
So we can't remove the if: dotvvm.isSpaRead condition
...but, we can replace it with `if: true`, which does not have the unwanted effect of hiding the content before everything loads. The reson is that ko.bindingContext/updateContext is pureComputed and won't update $data right after we replace the viewModel. We need someone to call `context[contextSubscribable]` to update it. Any binding will do that, but only after it's initialized, so the initialization will fail on "Property X was not defined". The pureComputed was introduced in knockout/knockout@0ac7010. It's probably not a knockout bug, as it's not possible to reproduce without our hacks with applyBindings in restoreUpdatedControls. If we used a binding handler for this, everything would be fine.
1 parent aa53fd3 commit a7f4b56

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/Framework/Framework/Controls/SpaContentPlaceHolder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ protected internal override void OnPreRender(IDotvvmRequestContext context)
109109

110110
protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
111111
{
112+
writer.AddKnockoutDataBind("if", "true"); // yep, go ahead and try to remove it
112113
base.AddAttributesToRender(writer, context);
113114
}
114115

src/Framework/Framework/Resources/Scripts/postback/updater.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export function updateViewModelAndControls(resultObject: any, updateTypeInfo: (t
6767

6868
// we have to update knockout viewmodel before we try to apply new data into the observables
6969
getStateManager().doUpdateNow()
70+
ko.tasks.runEarly()
7071

7172
// add new updated controls
7273
restoreUpdatedControls(resultObject, updatedControls);

0 commit comments

Comments
 (0)