[Catalyst] OT: JS no longer sucks,
(was Catalyst - any good AJAX tutes?)
Ashley
apv at sedition.com
Sat Mar 7 21:11:56 GMT 2009
On Mar 7, 2009, at 12:55 AM, kakimoto at tpg.com.au wrote:
> Basically, I am a web developer who hates JS and want to do minimal
> with
> it. Whatever I could get away with coding in perl, i would do it
> cause i
> know the language better and that it's more reliable. Js is dirty (or
> well, the newer incarnations might be good but heck).
I used to feel the same about JS. The language itself has improved
(I'm discovering ActionScript 3 is pretty damn cool too) and the kits
to wrap it in a cross-browser fashion are awesome. Even the ones I
think are not so great (like prototype) are still, objectively, quite
nice. And there are several that are great and just a matter of taste
or need. These are what I consider the best: Dojo (newer versions),
MooTools, YUI, ExtJs (I'm starting to not like it as much now that
the honeymoon is over), jQuery. The last being my personal choice:
write less, do more.
jQuery reminds me the most of Perl while actually looking nothing
like it. It's terse and immensely powerful. It gets out of your way
and for a CSS/XHTML dev, it's second nature.
The hide/show on the "tutorial" for example is done with two jQuery
commands — it could be chained as one but it decreases readability —
and gracefully degrading layout. This is the markup, two PREs, with
classes of "command" and "result."
<pre class="command">jinx at jasper[71]~>whoami</pre>
<pre class="result">jinx</pre>
This is the jQuery-
// Find what comes after a .command and hide it.
$(".command").next().hide();
// Put a click toggler on the .command elements to slideDown
// and slideUp.
$(".command").toggle(
function(){ $(this).next().slideDown() },
function(){ $(this).next().slideUp() }
);
And that's it! The markup is untouched if there's no JS enabled. So
it's just command/result. If there is JS, you get the neat show/hide.
Once you get the functional/callback style of code jQuery is
completely easy to sling.
> Thanks again, Ash. You rock.
Catalyst and jQuery make it easy, as I hope the example shows. By the
way, the site, sedition.com, is Catalyst powered and has been since
Friday, 1 December 2006. I'm trying, *again*, to rewrite the app
beneath in a general and robust way for CPAN release. :)
More information about the Catalyst
mailing list