* You are viewing the archive for the ‘JavaScript’ Category

JavaScript Code Block in Cake

Sometimes you need to trigger javascript functions or set variables in a view. With JavaScriptHelper, you do not have to print out the <script> tags. All you’ll need is calling a JavaScriptHelper function called codeBlock() function. The <script> tags will be generated itself and a CDATA too if you want it.

Make sure you have added JavaScriptHelper in your Controller where you’ll need the function.
In controller :
$helpers=array(’JavaScript’);

Method codeBlock($string=null, $options=array());
$string = JavaScript codes to be wrapped in <script> tags
$options = There are two parameters, $safe (boolean) and $allowCache (boolean)
The default … Continue Reading