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='/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='/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’t 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=”clock.js”>…</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’s method, and it is so complicated, and I have looked online, but haven’t found that people are having a problem with javascript and catalyst.

Emily
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to