Note that there are some explanatory texts on larger screens.

plurals
  1. POform not picking up javascript file
    text
    copied!<p>I am new to Cake PHP and I had a website with regular PHP and HTML, but now I am switinching to use Cake PHP. The issue I am having is that it is not picking up the javascript for a slider I have on a menu. (But it works on the original web).</p> <p>So I did the following steps, maybe you can see where I am making my mistake.</p> <p>First I put the Javascript file under <code>webroot/js</code></p> <pre><code>FILE javascript.js /** * */ $(document).ready(function() { //ACCORDION BUTTON ACTION $('div.accordionButton').click(function() { $('div.accordionContent').slideUp('normal'); $(this).next().slideDown('normal'); }); //HIDE THE DIVS ON PAGE LOAD $("div.accordionContent").hide(); }); </code></pre> <p>Then I went to AppController and added the following line under <code>cake/libs/controller/app_Controller</code></p> <pre><code>class AppController extends Controller { var $helpers = array('Html', 'Form', 'Javascript'); } </code></pre> <p>Then, that change allowd me to add it to layout</p> <pre><code> FILE mylayout.ctp &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt; &lt;?php $javascript-&gt;link('javascript.js'); &lt;/head&gt; &lt;?php include 'menu_nav.php';?&gt; //this has starting &lt;body&gt; tag &lt;?php include 'leftmenu_nav.php';?&gt; &lt;div id="content" class="divContent"&gt; &lt;div id="mainContent" class="divMainContent" style="text-align: left;"&gt; &lt;?php echo $content_for_layout; ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php include 'footer.php';?&gt; //this had end &lt;/body&gt; tag &lt;/html&gt; </code></pre> <p>Now somewhere in the </p> <pre><code>$content_for_layout </code></pre> <p>there some <code>&lt;divs&gt;</code> that make use of the JS, but for some reason 1) I do not see the JS markup when i do page source and 2) It is not sliding like it used to..</p> <p>Can anyone please tell me what I may be missing in this CakePHP config?.</p> <p>Thank you</p> <pre><code>echo $this-&gt;Html-&gt;script('javascript.js'); echo $this-&gt;Html-&gt;script('jquery-ui-1.8.16.custom.min.js'); echo $this-&gt;Html-&gt;script('jquery.js'); echo $this-&gt;Html-&gt;script('jquery.MetaData.js'); echo $this-&gt;Html-&gt;script('jquery.min.js'); echo $this-&gt;Html-&gt;script('jquery.rating.js'); echo $this-&gt;Html-&gt;script('jquery.rating.pack.js'); echo $this-&gt;Html-&gt;script('jquery.validate.js'); echo $this-&gt;Html-&gt;script('paging.js'); echo $this-&gt;Html-&gt;script('ui.datetimepicker.js'); echo $this-&gt;Html-&gt;script('format.js'); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload