Skip to content

.on() / .off() should be rewritten to save all bound events #21

Description

@itsrachelfish

Currently the only way to unbind an event is if the callback is passed to .off() specifically. If several functions need to be unbound, .off() would need to be called for each of them individually. Even worse, if the event callback is defined as an anonymous function there is no way to remove it.

It would be convenient if .on() stored all of the events being bound so they could later be unbound without passing a specific callback. For example:

$('.element').on('click', function()
{
    // This can't be removed!
});

// This would be convenient!
$('body').off();

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions