Skip to content

Undelegate doesn't work as advertised #24

Open

Description

@beatgammit

The API listed in the README is misleading. It says that I can do:

bean.undelegate(selector);

But calling this does absolutely nothing. On tracking it down, I found that delegate uses remove without any preprocessing. When I got to the remove function, it treated my selector as a an event. There was no logic differentiating a regular unbind (where the first element is an event name) and an undelegate.

Activity

  1. ded commented on Aug 24, 2011

    @ded
    Collaborator

    it's probably just advertised wrong... @fat?

  2. beatgammit commented on Aug 24, 2011

    @beatgammit
    Author

    Well, delegate works correctly, so I'm guessing undelegate didn't get any love.

    Right now, if I delegate something, then to remove listeners I remove them from the object, not the delegated object:

    $(selector).delegate(selector2, event, handler);
    $(selector).undelegate(event);
    

    I would much prefer doing something like:

    $(selector).undelegate(selector2, event);
    
  3. fat commented on Aug 26, 2011

    @fat
    Owner

    yeah -- $(selector).undelegate(selector2, event); isn't supported

  4. beatgammit commented on Aug 26, 2011

    @beatgammit
    Author

    Right now I just remove the watches from the top-level element. That works for now, but it's not the most elegant solution.

    Are there plans for supporting this? It kind of makes the 'undelegate' method useless, since it doesn't actually undelegate.

  5. fat commented on Aug 26, 2011

    @fat
    Owner

    Well, undelegate is just an alias for remove, much like delegate is an alias for add.

    With delegation you're just filtering events in an event listener... but at it's root, it's really just a regular event.

    If you want a cleaner way to add/remove these i highly recommend exploring namespaced events.

    That said, I would be happy to take a pull request for this -- but the likely hood of me getting around to this (among all the ender and bootstrap opensource work i have on my plate right now) is fairly unlikely.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions