Try addScript() -
http://api.cakephp.org/1.2/class_view.html#42c9e03d9fa609bd09d9530d9ee8266b
You can use it like that:
?php $this-addScript($javascript-link(array('jquery','ui.tabs'))); ?
?php $this-addScript($javascript-codeBlock('$(function() { $
(#album-data ul).tabs(); });')); ?
?php
in cake 1,2 How do you add a javascript function in just one of my views? I
don't want to put it in the layout because i don't need the JS in all of the
pages.
There are 2 cases:
1. I want to add echo $javascript-link(array(js_file)); to one of my view
ctp file
2. I want to add a body onload=JS
1. Make sure in your layout, in the head you have this:
?php echo $scripts_for_layout; ?
Then, in whatever view you need to add the script, just do:
?php $javascript-link('js_file', false); ?
(the `false` parameter means it isn't processed directly [hence no
need for `echo()`] but added