Rohit
Rohit

Reputation: 189

Cakephp jQuery default load

I am a newbie in cakephp framework. Basically I am following this guide http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html to get up and running with jQuery in cakephp

But when I try to load

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

in default.ctp .. it is loaded in my view but in console I get an error

$ is not defined.

(The famous jQuery error :p)

But when I load it externally any jQuery file.. it seems to work fine. I want to make a plugin with no dependencies and use cakephp own jQuery

Am I doing something wrong ?

Please help

Upvotes: 0

Views: 404

Answers (4)

Vivek S
Vivek S

Reputation: 2051

You must include js file into the webroot/js folder to use the corresponding js file.

Upvotes: 1

XuDing
XuDing

Reputation: 2052

Do you have app/webroot/js/jquery.js in place?

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

is referring to the path.

Upvotes: 0

adriaroca
adriaroca

Reputation: 172

Try it:

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

Upvotes: 0

Anubhav
Anubhav

Reputation: 1623

Try

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

Hope it will work!

Upvotes: 0

Related Questions