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

DEMO: Action helper. No more data-user-id needed. #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smfoote
Copy link
Owner

@smfoote smfoote commented Jul 17, 2015

Because the listener has the context/model within closure scope, no need to do model lookups when the event happens.

let {selector, type, method} = params;
type = type || 'click';
let frag = bodies.main(context);
frag.querySelector(selector).addEventListener(type, context[method].bind(context));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if this would be useless, but maybe you could allow binding to a different context:

let boundContext = params.context || context;
frag.querySelector(selector).addEventListener(type, context[method].bind(boundContext));

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

Successfully merging this pull request may close these issues.

2 participants