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

How to wrap the default taBind event handler? #493

Closed
geyang opened this issue Jan 16, 2015 · 6 comments
Closed

How to wrap the default taBind event handler? #493

geyang opened this issue Jan 16, 2015 · 6 comments

Comments

@geyang
Copy link
Collaborator

geyang commented Jan 16, 2015

Hi @SimeonC ,

I have a few custom directives inside the editor, so some of the keydown events in the editor needs to be handled differently.

I am trying to wrap the taBind event handler but failing. Here is how I did it:

in my directive:

taBindHandler = iElement.off('keydown');
... my code..
... more code...
taBindHandler(event);

but I realized that the taBindHandler returned from the iElement.off() is the element itself, not an event handler. How to get the event handler instead?

Thanks!

@SimeonC
Copy link
Collaborator

SimeonC commented Jan 20, 2015

I think I should implement some ng-keyup kind of interaction for the taBind directive as I don't think the event handler is accessible outside of the directive itself.

@geyang
Copy link
Collaborator Author

geyang commented Jan 20, 2015

Hey,

So if we can save the keydown handler in the scope, it would be fairly easy to wrap.

Do you think something along the line of

scope.onKeydown = function onKeydown () {
blah blah
}

iElement.on('keydown', onKeydown);

would work?

Ge

@SimeonC
Copy link
Collaborator

SimeonC commented Jan 20, 2015

That would work in theory. If there's a way of accessing the taBind's isolated scope? I can't think of one off the top of my head.

@geyang
Copy link
Collaborator Author

geyang commented Jan 21, 2015

I was able to do that following your example code in one of the issues.

So in app.configure, I bind another directive to the ta-bind element. Then
I am able to isolate the scope.

Ge

On Tue, Jan 20, 2015 at 4:24 PM, Simeon Cheeseman notifications@github.com
wrote:

That would work in theory. If there's a way of accessing the taBind's
isolated scope? I can't think of one off the top of my head.


Reply to this email directly or view it on GitHub
#493 (comment)
.

@SimeonC
Copy link
Collaborator

SimeonC commented Jan 21, 2015

Ok, I've added in an events object to the taBind scope. Its now scope.events.keydown. Will be in next patch, hopefully a full 1.3.0 so you may have to wait a day or two for the one outstanding issue to be confirmed resolved.

@geyang
Copy link
Collaborator Author

geyang commented Jan 21, 2015

No worries! I have been pretty much working with my fork, so it will take
me a day or two to merge rebase with your master again.

Thanks for this great library! and sorry for not following up with my PR
with tests. It took some solid 4 weeks to get the code bullet-proof in
Chrome. Right now there are a few problems in safari and firefox.

I think actually if you have time (and I understand if you are busy), it
might be helpful if you can lend a hand.

Ge

On Tue, Jan 20, 2015 at 8:26 PM, Simeon Cheeseman notifications@github.com
wrote:

Ok, I've added in an events object to the taBind scope. Its now
scope.events.keydown. Will be in next patch, hopefully a full 1.3.0 so
you may have to wait a day or two for the one outstanding issue to be
confirmed resolved.


Reply to this email directly or view it on GitHub
#493 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants