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

optionsText with a lambda value fails to resolve the function argument #146

Closed
danieldickison opened this issue Jul 13, 2021 · 2 comments
Closed

Comments

@danieldickison
Copy link
Collaborator

I tried a lambda (arrow-function) value for optionsText, following the knockout docs’ example, which uses a function value:

<select data-bind="
    options: possibleUsers,
    optionsText: (user) => formatUser(user),
    value: selectedUser
"></select>

This fails with:

Message: The variable &quot;user&quot; was not found on $data, $context, or globals.

Specifying the optionsText as a function reference does work: optionsText: formatUser

Demo: https://jsfiddle.net/danieldickison/az2on6h0/4/

@danieldickison danieldickison changed the title optionsText with a lambda value resolve the function argument optionsText with a lambda value fails to resolve the function argument Jul 13, 2021
@brianmhunt
Copy link
Member

Good find, thanks. This would seem to be a problem with the bindingContext lookup function.

A PR with a failing test would be a good starting point.

Glad you've a workaround with the formatUser, in the interim.

@danieldickison
Copy link
Collaborator Author

danieldickison commented Aug 4, 2021

Tests in #151 and it looks like lambda parameter lists aren't being evaluated at all at the moment, and multiple parameters fail to parse. I've been looking at parser.ts but haven't quite wrapped my head around how all the parts fit together.

@brianmhunt do you think you would be able to look into this soon? If not, I'll continue developing a fix in the parser over the next couple of days.

edit: the pull request now has a fix for this in it.

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