2013-12-19 92 views
0

我是cakephp框架中的新手。基本上我按照本指南http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html起牀,在CakePHP中Cakephp jQuery默認加載

與jQuery運行但是當我嘗試加載

<?php echo $this->Html->script('jquery'); ?> 

在default.thtml中..它裝在我的看法,但在控制檯中我得到出錯

$未定義。

(著名的jQuery的錯誤:P)

但是,當我加載它外部的任何jQuery的文件..這似乎很好地工作。我想做一個沒有依賴關係的插件,並使用cakephp自己的jQuery

我做錯了什麼?

請幫

+0

檢查這個問題: http://stackoverflow.com/questions/10708599/cakephp-2-x-jquery-easyui-how-to-put-jquery-easyui-in-cakephp-2-x – 2013-12-19 10:58:59

+0

請看到螢火蟲,並確保它正在加載或它有一些衝突 –

+0

檢查jQuery的路徑 –

回答

0

嘗試

echo $this->Html->script('jquery'); 

希望它會工作!

+0

我使用回顯很明顯:p 實際上它無法加載 – Rohit

+0

在這種情況下,您正在使用一些其他js文件,其中你重寫jQuery的默認對象,例如$,檢查其他js文件,同時檢查firebug是否顯示jQuery js – Anubhav

0

試試:

$this->Html->script(array('jquery.js')); 
$this->fetch('script'); 
0

你有沒有到位的應用程序/ Web根目錄/ JS /的jquery.js?

echo $this->Html->script('jquery'); 

指的是路徑。

1

您必須將js文件包含到webroot/js文件夾中才能使用相應的js文件。