Andrea Ercolino schrieb:
> I hope the event shortcuts will remain, like click( handler ) to bind and
> click() to trigger.
>   
So far bind() would be on() and unbind() would be un(). The shortcuts 
would be removed from the default distribution, but still available as a 
compatibility plugin.
> As for the bind style, I think the handler should always be the last
> argument, because to me it's cleaner this: 
>
> $( "div" ).bind( "click", {amount: 1}, function() {
>       doClick();
> } );
>
> than this:
>
> $( "div" ).bind( "click", function() {
>       doClick();
> }, {amount: 1} );
>   
How about this:
var handler = function() { ... };
$("div").bind("click", handler, {amount: 1});
> Sure having the function at the bottom makes optional arguments a little
> more complitated, and if you think it's better to avoid all those type
> checking in the code (I think the same) then the solution is to have no
> optional arguments at all, like this:
>
> $( "div" ).bind( "click", {}, function() {
>       doClick();
> } );
>
> This style adds a bit of self-documentation to the script, making it clear
> that we are using default values for the second argument.
>   
But the empty object would be still be passed around, creating 
unncessary overhead. The "default" is nothing, therefore you should at 
least use null as the second argument. Still I don't like an API that 
forces me to pass null around all the time.

-- 
Jörn Zaefferer

http://bassistance.de


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

Reply via email to