> IMO, part of good software craftmanship and being productive is being
> able to recognized code in brain speed. One might called say the art
> of "jQuery Theory" dissemination of information  applies here.

I agree! Also, something yet unaddressed in this thread is callbacks.

I really enjoy the hierarchy of nested anonymous functions because the
nesting allows me to easily read the timing of a list of events.
Events that are chained like .click().toggle() says to me "All these
events run at once without waiting." Plus, coded, I write chained
events like so:

$('#div').click( function() {
     alert('Clicked!');
}).slideUp( 300, function() {
  alert('Sliding up!');
}).toggle();

And I write nested callbacks like so:

$('#div').click( function() {
     alert('Clicked!');
  }, function() {
     $(this).slideUp( 300, function() {
          alert('Sliding up AFTER click!');
       }, function() {
          $(this).toggle("fast", function() {
               alert('Toggle AFTER slide');
          });
     });
});

Well, the difference is much clearer in a proper editor, but the point
is that code design in jQuery is what makes it so easily readable, due
to the overloaded functions.  I can't imagine how callbacks would look
in the proposed 'reduction'.  Any callback is likely to make the code
more than one line anyway, rendering the 'reduction' irrelevant, IMO.

Although the anonymous functions may look ugly now, we've gotten
spoiled by the 'unobtrusive javascript'.  Remember how unreadable
scattered onMouseover="" 's all over our HTML was?  Event bindings and
fx can only get so simple.

I enjoy the new ideas, though, it's given me a new appreciation for
jQuery's structure.

Charles
doublerebel.com

On Aug 18, 2:41 am, "Dragan Krstic" <[EMAIL PROTECTED]> wrote:
> I'm always for separating thing. Maybe, this would be nice:
>
> Function my_f(arg1,arg2,arg3)
> {
>      //code
>
> }
>
> $("...").click().f_call("my_f",{arg1: "arg1",arg2: "arg2",arg3: "arg3"});
>
> or similar.
>
> Maybe, plug in mechanism can be extended to do this stuff.
>
> John, for us who prefer
> $(...).bind("click",f(){});
>
> over
> $(...).click();
>
> how to to rewrite:
> $(...).onclick().toggle().end();

Reply via email to