> The way I coded the trigger and handle functions in my system it worked 
> like this (or at least it should. This is untested but theoretically 
> sound and the way I intended for it to work).
> 
> $().click(fn1,arg1,arg2);
> $().click(fn2,arg3,arg4);
> // someone clicks there
> // fn1 runs with arguments [event,arg1,arg2]
> // fn2 runs with args [event,arg3,arg4]
> $().trigger('click');
> // fn1 runs with args [event,arg1,arg2]
> // fn2 runs with args [event,arg3,arg4]
> $().trigger('click',arg5,arg6);
> // fn1 runs with args [event,arg1,arg2,arg5,arg6]
> // fn2 runs with args [event,arg3,arg4,arg5,arg6]
> 
> To me this is the least surprising result, would you agree?

No. The general idea of passing arguments via trigger and bind is to modularize 
code. Think of a big system where you can't rely on closures. Or where you want 
to pass arguments to a plugin via trigger. The event handler maybe implemented 
by the user, while the argument to bind are coming from plugin code and may 
change.

With your implementation, the handler had no idea how to identify which 
argument was passed via bind and which via trigger, but that is important.

--
Jörn Zaefferer

http://bassistance.de
-- 
"Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de
Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht!

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to