简体   繁体   English

如何在cakephp 1.3中包含javascript?

[英]How to include javascript in cakephp 1.3?

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. 这是包含CSS,HTML,jQuery代码的幻灯片代码。

This slide works fine, but when I include this slide in cakephp it is not working. 这张幻灯片效果很好,但是当我将这张幻灯片包含在cakephp中时,它将无法正常工作。

I put jQuery files and CSS in webroot and put the code to include in layout/default.ctp like this 我将jQuery文件和CSS放在webroot中,然后将代码包含在layout / default.ctp中,如下所示

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.. 但是仍然没有任何反应..请任何人帮助我..下载幻灯片并尝试单击顶部以幻灯片显示图片..然后将其包含在cake ..中,您将发现问题..

a) you shouldnt use $javascript anymore. a)您不应该再使用$ javascript。 it would be $this->Javascript 这将是$ this-> Javascript

b) javascript itself is deprecated (see the documentation) b)不建议使用javascript本身(请参阅文档)

so use 所以用

$this->Html->script()

details: http://book.cakephp.org/view/1589/script 详细信息: 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: 这是我让e Jquery Slider在Cake生成的页面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. 我将js文件放在webroot / js / libs中,将css文件放在webroot / css中-注意:保留了.js和.css扩展名。

<?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 我将滑块HTML放在体内的某个位置

I put the Slider Javascript: script type="text/javascript" right before the closing /body tag.. 我将Slider Javascript:script type =“ text / javascript”放在结束/ body标签之前。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM