[Catalyst] javascript in Catalyst using Template Toolkit
John Romkey
romkey at apocalypse.org
Thu Dec 20 19:11:50 GMT 2007
Two recommendations, assuming the Javascript file isn't meant to be =
modified at runtime:
First, use an absolute path to the file in your script tag, ie: =
<script src=3D'/static/clock.js'> or use $c->uri_for() to compute the =
path.
Second, serve the Javascript file from your static directory so that =
Catalyst is bypassed. This will help performance and caching as well =
(I embed version numbers in the filenames to help avoid new code from =
getting old cached versions of my Javascript files, so I would have =
something like <script src=3D'/static/clock-0.1.js'> in my code).
If those don't solve the problem, what turns on up the Javascript =
console of your browser? Is the script file just not being found or is =
your browser getting errors trying to execute it?
- john romkey
http://www.romkey.com/
On Dec 20, 2007, at 1:47 PM, Emily Heureux wrote:
> I am trying to execute a bit of external javascript code, but I =
> don=92t believe I am setting it up correctly in Catalyst. I have a =
> clock.js file, and then inside a menu file in myapp/root/lib/site I =
> have the script tag: <script src=3D=94clock.js=94>=85</script>.
>
> If I put the clock.js code directly into the menu file, and not in =
> an external js file, I can get it to work. It is badly done =
> though. I have an extra body tag to call an onload function, but it =
> works. Does anyone know how to set up the different pieces so that =
> I can have the javascript in an external file? I have seen a =
> friend=92s method, and it is so complicated, and I have looked online, =
> but haven=92t found that people are having a problem with javascript =
> and catalyst.
>
> Emily
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.or=
g/
> Dev site: http://dev.catalyst.perl.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071220/ff187=
879/attachment.htm
More information about the Catalyst
mailing list