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

Unable to pass event object when firing a native key(up|down) event #72

Open
afbobak opened this issue Aug 17, 2012 · 1 comment
Open

Comments

@afbobak
Copy link

afbobak commented Aug 17, 2012

Basically I'm trying to do this:

$("input").fire("keydown", {
  type: "keydown",
  keyCode: 191
});

If I read the code correctly it should fix the half-baked event I pass in as a second argument and then go through all the listeners and call the handler with the fixed event.

In practice fire() prepends the boolean false (line 517) to the arguments which then gets passed to the nativeHandler's handler (line 334) but the handler expects the argument "event" as the first argument, which now is always false and thus always fixes the wrong event object.

When I change the nativeHandler's handler to

handler = function (f, event)

then things work with no apparent side-effects.

What's the reason the false prepended?

@rvagg
Copy link
Collaborator

rvagg commented Aug 18, 2012

The 'args' are meant to be additional arguments to the event handler rather than the Event object itself. There is scope though to implement proper Event object handling but it's not in there at the moment.
It's possible that we could squeeze something into the upcoming 1.0 release since it would likely be an API breaking change, or at a minimum we could make room for it in 1.0 for implementation in 1.1 perhaps.
If you feel like contributing, the 1.0 code is in the 0.5-wip branch, there's a write-up here about what's in it and the API breakages: http://rod.vagg.org/2012/08/bean_v1/

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