Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling static command service methods with NamedCommand Arguments #1165

Closed
Rumbeer opened this issue Oct 8, 2021 · 2 comments
Closed

Calling static command service methods with NamedCommand Arguments #1165

Rumbeer opened this issue Oct 8, 2021 · 2 comments

Comments

@Rumbeer
Copy link
Contributor

Rumbeer commented Oct 8, 2021

Not sure if I am doing something wrong but I am unable to call static command service method with NamedCommand arguments.

View:

<dot:NamedCommand Name="LoadHotSpotDetail"
        Command="{staticCommand: (string hotSpotId) => _root.SelectedHotSpot = hotSpotService.LoadHotSpotDetail(hotSpotId).Result}" />

Call from js:

await this.context.namedCommands["LoadHotSpotDetail"](marker.model.Id);

I get this console error after calling the command:

dotvvm--internal:52 static-command Unexpected exception during static command. ReferenceError: hotSpotId is not defined
    at eval (eval at createBindingsStringEvaluator (knockout:3293), <anonymous>:5:302)
    at new Promise (<anonymous>)
    at eval (eval at createBindingsStringEvaluator (knockout:3293), <anonymous>:4:9)
    at ModuleContext.eval (eval at createBindingsStringEvaluator (knockout:3293), <anonymous>:7:98)
    at saneNext (dotvvm--internal:2821)
    at nextWithCheck (dotvvm--internal:2881)
    at recursiveCore (dotvvm--internal:2890)
    at dotvvm--internal:2893
    at Object.execute (dotvvm--internal:2294)
    at recursiveCore (dotvvm--internal:2893)

When I separate the the commands into two so I just assign the hotSpotId to a view model property in one static command and call the static command service method without arguments from NamedCommand in the second one everything works fine.

I also tried using command that calls a method on view model with NamedCommand arguments and it wasn't called at all either.

@mrnustik
Copy link
Contributor

mrnustik commented Oct 8, 2021

This is known bug: #980
Unfortunately it is not yet fixed, because it requires dropping support for Internet Explorer.

@Rumbeer
Copy link
Contributor Author

Rumbeer commented Oct 8, 2021

Alright, didn't know that. Gonna close this issue then.

@Rumbeer Rumbeer closed this as completed Oct 8, 2021
exyi added a commit that referenced this issue Oct 14, 2021
The parameters were passed in a very weird way, now it works similar
to command bindings - even when command is not a lambda function, it is
wrapped in a lambda function. Then, the lambda function gets parameters
assigned directly, so the lambda syntax is essentially eliminated.
This back and forth is kinda needed to align how it works in case command
is specified as plain expression and when it's specified as
lambda function.

resolves  #980, #1165
exyi added a commit that referenced this issue Oct 16, 2021
The parameters were passed in a very weird way, now it works similar
to command bindings - even when command is not a lambda function, it is
wrapped in a lambda function. Then, the lambda function gets parameters
assigned directly, so the lambda syntax is essentially eliminated.
This back and forth is kinda needed to align how it works in case command
is specified as plain expression and when it's specified as
lambda function.

resolves  #980, #1165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants