-
Notifications
You must be signed in to change notification settings - Fork 102
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
Unbind events/delegations #156
Comments
Bliss does store listeners, so that would be pretty easy to implement. |
Unbinding events requires to pass handler function, so it's not very convinient to bind with anonymous function as I cannot unbind such events without getting inside Bliss listeners storage. I haven't thought about any specific API call example - I just need a way to do that. A jQuery-like mechanism with ability to "name" or "group" events by "class name" and unbind events with that class name would be nice. jQuery example: $('a').click(function() { /* ... */ });
$('a').bind('click.someName change.someName', function() { /* ... */ });
$('a').bind('click.someOtherName', handlerFunction);
$('a').unbind('.someName');
// two event handlers still attached, one click and one change event removed
$('a').unbind('click');
// no event handlers left So maybe this should be equivalent: $('a')._.events({
'click': function() {},
'click.someName change.someName': function() {},
'click.someOtherName': handlerFunction
});
$('a')._.removeEvents('.someName');
// same effect as above
$('a')._.removeEvents('click');
// no events left
// This should also work:
$('a')._.removeEvents(); // will remove everything
$('a')._.removeEvents('click change'); // will remove everything in this example
$('a')._.removeEvents('click.someOtherName click.someName'); // will leave change and "classless" click event |
This is definitely useful functionality that I'm interested in implementing. |
Do you think this should only apply to events attached via |
PERSONALLY I would like it to work with addEventListener too. I don't know about the others. I never heard about naming events with periods. A notice in the docs would be enough for me. |
It’s actually much easier to implement that way, so that’s what I’m doing. |
Awesome, thanks. |
@dzek69 I pushed and added some docs :) It still needs tests though. |
Documentation doesn't say a word about that. Ability to handle events as easy as in jQuery would be nice.
The text was updated successfully, but these errors were encountered: