On Aug 17, 11:50 am, "John Resig" <[EMAIL PROTECTED]> wrote:
> However, I'm currently leaning away from it (embedding code in strings
> is messy) in favor of another solution that I'm working on:
> $(...).onclick().toggle().end();
> Removing the need for anonymous functions entirely.

Only if your entire click() funtionality consists of jquery calls,
correct? If I simply wanted to alert, I would still need to use an
anonymous function?

Your syntax above reminds me of functionality I built into my own
custom framework a while ago:

$(el).repeat(10).css("background-color:red").wait(.5).css("background-
color:white").start();

This would flash a background 10 times with a 1/2 second pause between
colors.
The implementation wasn't complex - the repeat() function just
returned a "shell" object that chomped up the following commands into
a buffer which would be executed when start() was called. Same thing
with wait() - it would eat up the following commands so that a
setTimeout() could be called and execution could continue when the
pause was done. The end result was some kind of slick-looking code in
some places. But more of a mental exercise than anything extremely
practical ;)

Matt Kruse



Reply via email to