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

Binding functions with correct context, in templates #3

Closed
andrewdavey opened this issue Sep 2, 2010 · 1 comment
Closed

Binding functions with correct context, in templates #3

andrewdavey opened this issue Sep 2, 2010 · 1 comment

Comments

@andrewdavey
Copy link

When binding a function to a click (in a template) the "this" of the function is not set to the view model.
Execute

Instead, I have to do this:
Execute

Can this be improved to match the former example?

@SteveSanderson
Copy link
Contributor

Good point - I've just commited a tweak that hopefully does just what you want. Please try the latest source code version from http://github.com/SteveSanderson/knockout/tree/master/build/output/ and see if it does.

It will set 'this' to be whatever "data" value the template is using (i.e., $data if you're using the default template engine), so if you have nested templates, it will use the "data" value from the current level of nesting. This is much more useful than the previous behaviour of not setting any particular "this" value when invoking click/submit/etc binding functions.

This issue was closed.
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