[Catalyst] Catalyst and CGI::Ajax

Peter Karman peter at peknet.com
Wed May 23 22:21:30 GMT 2007



Petri Ruutikainen wrote on 5/23/07 3:59 PM:
> Hi!
> 
>  
> 
> Is there anyhow possible to include CGI::Ajax to Catalyst using Template
> Toolkit (TTSite)? I know that using Prototype one can get Ajax functionality
> to Catalyst but I have been unable to initiate that. Or is there some more
> detailed tutorial about the matter (Ajax or Prototype used with Catalyst)
> besides the Catalyst tutorial and/or Cookbook? A big thanks to anybody who
> will be answering and setting me to the right (or left) track.

IME using Ajax without any kind of Catalyst plugin or explicit view is pretty 
painless. Just include the relevant libraries in the .tt files, write the 
javascript to use them in your .tt files, and then write controller code to 
handle the requests. The pitfalls I have stumbled into have been more with the 
javascript itself rather than anything particularly Catalystic.

Understanding the relationship between your js and your Cat code (the request 
and response cycle) is important when it comes time to debug, and using the 
wrappers can (IME) actually impede the learning because there's simply too much 
magic going on.

See the example app here for how I do it with Prototype and Scriptaculous:
http://search.cpan.org/src/KARMAN/Catalyst-Controller-Rose-0.02/t/examples/CatRose/

And yes Dojo/Mocha/YUI/lib-de-jour lovers, I know Prototype isn't cool anymore. ;)

-- 
Peter Karman  .  http://peknet.com/  .  peter at peknet.com



More information about the Catalyst mailing list