Open beatgammit opened 13 years ago
it's probably just advertised wrong... @fat?
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);
yeah -- $(selector).undelegate(selector2, event);
isn't supported
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.
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.
The API listed in the README is misleading. It says that I can do:
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.