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

Allow bean.off to use selectors as bean.on does #127

Open
jotadepicas opened this issue Mar 16, 2016 · 3 comments
Open

Allow bean.off to use selectors as bean.on does #127

jotadepicas opened this issue Mar 16, 2016 · 3 comments

Comments

@jotadepicas
Copy link

Hi,
I'm currently using:

bean.on(element, 'click', '[my-selector]', myHandler)

But I cannot use:

bean.off(element, 'click', '[my-selector]', myHandler)

Since according to the documentation bean.off only accepts this arguments:

off(element[, eventType[, handler ]])

In fact, my event is not removed and then when bean.on executes again, is added multiple times.
It makes sense to me that if bean.on allows for selectors to be used, then bean.off should too, right?

Thanks!

@jotadepicas
Copy link
Author

I'm not sure, but could it be that events added with selectors, in fact cannot be removed at all?

@Sirk
Copy link

Sirk commented Mar 28, 2017

+1

@Sirk
Copy link

Sirk commented Mar 28, 2017

@jotadepicas You can actually fix this issue if you trick a little bit, using namespace, you can

bean.on(element, 'click.yournamespace', 'your-selector', yourHandler)

and off the event with

bean.off(element, '.yournamespace')

Hope this can help. But it would be really nice to investigate to allow off() to use delegation.

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