How to include javascript in cakephp 1.3?

会有一股神秘感。 提交于 2019-12-04 20:55:36

a) you shouldnt use $javascript anymore. it would be $this->Javascript

b) javascript itself is deprecated (see the documentation)

so use

$this->Html->script()

details: http://book.cakephp.org/view/1589/script

This is what I did to get e Jquery Slider working on a Cake generated page default.ctp:

I dropped my js files in webroot/js/libs and css files in webroot/css - NOTE: That the .js and .css extensions are left off.

<?php
 echo $this->Html->css('royalslider', null, array('inline' => true));
 echo $this->Html->css('royalslider-skins/default/default', null, array('inline' => true);
 echo $this->Javascript->link('libs/jquery-1.6.2.min', true);
 echo $this->Javascript->link('libs/jquery.easing.1.3.min', true);
 echo $this->Javascript->link('libs/royal-slider-7.9.min', true);
 echo $scripts_for_layout;
endif;
?>

I put the slider HTML somewhere in the body

I put the Slider Javascript: script type="text/javascript" right before the closing /body tag..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!