What exactly do you mean when you say the handler doesn't know which
argument is passed via trigger versus bind? Can you give me an example
of this so I can better understand the problem?
-blair
Jörn Zaefferer wrote:
>> 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
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/