[Catalyst] Using JQuery in Catalyst

Joe Landman landman at scalableinformatics.com
Sun Jul 15 16:32:21 GMT 2007

Replying to self after more experimentation.  I figured what I found 
might help others.

Joe Landman wrote:

>   Are any Cat users using JQuery, and if so, are you doing it on your 
> own, or leveraging the JQuery modules?  Basically I am looking at them 
> as an easy way to avoid writing javascript/css for some of the 
> presentation elements (tabs for example).  Basically I want to hand an 
> object an appropriately constructed data structure and have it do all 
> the work of generating the javascript.  I had thought the JQuery modules 
> did this.

They sorta kinda do this. JQuery comes with the css/modules set up in 
directories of its own.  Of course, it is setup in such a way that if 
you follow the documentation, it won't work.

What you have to do is

  	cd to where ever you point jqueryDir to, then ...
	ln -s /usr/lib/perl5/site_perl/5.8.8/JQuery/jquery_js/jquery \
	ln -s /usr/lib/perl5/site_perl/5.8.8/JQuery/jquery_js/plugins \

This is just to set up the paths to the plugins.  You can cp -r instead 
if you want to incorporate them.

Then in your code, you need to add

	my $code = $jquery->get_jquery_code ;
	my $css  = $jquery->get_css ;

and then somewhere before the body ends ...

	<% $code %>
	<% $css  %>

( for the TT/TT2 enhanced/encumbered, this should be something like
	[% $code %]
	[% $css  %]
   or some such thing )

Also the example on the JQuery module page is incorrect, you need to add 
in a
	addToJQuery => $jquery ,

element.  Kind of a pseudo class/object thingy.  Not one and not the 
other.  Something in-between.

I will document what I found and send a ticket over to Peter Gordon 
soon.  Is there a JQuery plugin or similar being worked on for Catalyst?



Joe Landman
landman at scalableinformatics.com

More information about the Catalyst mailing list