Skip to content

Commit

Permalink
Merge pull request #1045 from riganti/fix-complex-postback-handler-bi…
Browse files Browse the repository at this point in the history
…nding

Fix complex postback handler binding
  • Loading branch information
quigamdev committed Jun 9, 2021
2 parents 33e0dfe + 38d72c7 commit 73ea46d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Expand Up @@ -106,8 +106,7 @@ public override string ToString()

public string GetParameterlessResult()
{
if (parameters != null) throw new InvalidOperationException($"The script contains parameters: `{ToString()}`.");
return result.ToString();
return GetResult(OperatorPrecedence.Max).ToDefaultString();
}

public ParametrizedCode GetResult(OperatorPrecedence operatorPrecedence)
Expand Down
12 changes: 8 additions & 4 deletions src/DotVVM.Framework/Controls/KnockoutHelper.cs
Expand Up @@ -267,10 +267,14 @@ private static JsExpression TransformOptionValueToExpression(DotvvmBindableObjec
{
switch (optionValue)
{
case IValueBinding binding:
return new JsIdentifierExpression(
JavascriptTranslator.FormatKnockoutScript(binding.GetParametrizedKnockoutExpression(handler, unwrapped: true),
new ParametrizedCode("c"), new ParametrizedCode("d")));
case IValueBinding binding: {
var adjustedCode = binding.GetParametrizedKnockoutExpression(handler, unwrapped: true).AssignParameters(o =>
o == JavascriptTranslator.KnockoutContextParameter ? new ParametrizedCode("c") :
o == JavascriptTranslator.KnockoutViewModelParameter ? new ParametrizedCode("d") :
default(CodeParameterAssignment)
);
return new JsSymbolicParameter(new CodeSymbolicParameter("tmp symbol", defaultAssignment: adjustedCode));
}
case IStaticValueBinding staticValueBinding:
return new JsLiteral(staticValueBinding.Evaluate(handler));
case JsExpression expression:
Expand Down

0 comments on commit 73ea46d

Please sign in to comment.