Thoughts about delegation

Thoughts about delegation

So I really want event delegation in jQuery 1.3:
http://docs.jquery.com/JQuery_1.3_Roadmap
I've been thinking of ways that we can make it better and more jQuery
like (especially with the new .selector property that I propose). I
have a couple thoughts:
Binds to $("#container") and watches for all clicks, filtering against
the expression "div" - a fast LiveQuery substitute:
$("#container div").delegate("click", function(){});
Binds to document look for all div:
$("div").delegate("click", function(){});
Switch against multiple filter types, still bound to #container:
$("#container (.open, .closed)").delegate("click", function(e){
switch(e.filter){
case: ".open":
case: ".closed":
}
});
Or - First function handles .open, second handles .closed:
$("#container (.open, .closed)").delegate("click", function(){}, function(){});
Naturally if there was more than one container then a delegation would
be bound to each, individually:
$("div > span").delegate("click", ...);
And all of this will even work with the native methods!
$("#container").children(".foo").delegate("click", ...);
Naturally it won't be able to work directly with stuff like +, ~,
parent, parents, next, nextAll, prev, and prevAll since they aren't
actually contained within the original container. But this could work:
$("#container").find("div").next().delegate("click", ...);
If we wanted to, we could even explore firing DOM-related events
(add/remove/modify) if a delegation method is bound:
$("#container li").delegate("added", function(){
$(this).addClass("test"); // li now has a class of test
});
I realize that this changes the actual meaning of "delegate" - we may
want to use different terminology "awesomeBind" hehe.
Thoughts?
--John