dave.methvin wrote:
> 
> Then there is the classic ambiguity of .unload(). Does it call an onunload
> handler, or does it unbind all onload handlers? There is no doubt with
> .un("load") or .on("unload", fn) which are only a few characters longer. 
> 

OK. But I don't think that "on" and "un" are better names than "bind" and
"unbind", the former are shorter but the latter mean exactly what they say,
no explication necessary.

Let's summarize.

Having 
        fn = function() {...}

this is the old verbose style enhanced
        $( "div" ).bind( "click", fn, {count: 1} ).trigger( "click", {bubble: 
true}
).unbind( "click", fn );

this is the almost (except for trigger) brand new style
        $( "div" ).on( "click", fn, {count: 1} ).trigger( "click", {bubble: 
true}
).un( "click", fn );

this is the old shortcut style enhanced and revisited
        $( "div" ).click( fn, {count: 1} ).click( {bubble: true} ).click( 0, fn 
);

Just a little thing: a prefix like "e_" would come in handy in at least two
occasions.
(1) a text search in a script: searching for ".e_" hops from each event
handling snippet to the next
(2) the functions index in the API documentation, for grouping event
supporting functions together
        $( "div" ).e_click( fn, {count: 1} ).e_click( {bubble: true} ).e_click( 
0,
fn );

And what about this :)) ? It is almost what we already have and makes it
possible to tune the search... ;-)
        $( "div" ).e_onClick( fn, {count: 1} ).e_doClick( {bubble: true}
).e_unClick( fn );
        $( "div" ).e_onLoad( fn, whatever ).e_doLoad( whatever ).e_unLoad( fn );
        $( "div" ).e_onUnload( fn, whatever ).e_doUnload( whatever 
).e_unUnload( fn
);

enough brainstorming

-- 
View this message in context: 
http://www.nabble.com/jQuery-1.1-API-improvements-%28macros%2C-events%29-tf2713203.html#a7570741
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to