问题
Wait moment this question not duplicated..it is sample and difficult at the same time.
This simple problem make me crazy..
http://www.mediafire.com/?2vi2kc7tpqiw1to
This is slide code contain CSS, HTML, jQuery code.
This slide works fine, but when I include this slide in cakephp it is not working.
I put jQuery files and CSS in webroot and put the code to include in layout/default.ctp like this
echo $javascript->link('jcookie.js');
echo $javascript->link('jquery-1.3.2.min.js');
echo $javascript->link('jcarousellite.js');
echo $javascript->link('jquery-1.js');
but still nothing happen ..please anyone help me..download the slide and try to click on the top to slideshow pictures..and then include it in cake..you will find the problem..
回答1:
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
回答2:
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..
来源:https://stackoverflow.com/questions/8191877/how-to-include-javascript-in-cakephp-1-3