MCHam
MCHam

Reputation: 319

Using my own Javascript in Cakephp

So What I want to do is use a javascript called nicEdit.js in this one app, but don't want it used in all app that uses the "default.ctp" template.

  1. I've added the Js to /webroot/js/nicEdit.js
  2. Based on this tutorial "http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html", I have added "public $helpers = array('Js' => array('nicEdit'));" at the beginning of my Controller.
  3. I did a "view source" on my browser to see where the js is being loaded and I don't see it anywhere.

What am I missing?

Upvotes: 0

Views: 122

Answers (1)

Matt Cain
Matt Cain

Reputation: 5768

To include a script on your page you can use the HTMLHelper in either a layout or a view, like this:

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

Upvotes: 1

Related Questions