How to add a bootable jquery script to cakephp 2.5.5?
I'm trying to add some simple jquery bootstrap functionality to cakephp 2.5.5, but I don't know how to add the script to view. Please suggest me some code?
in jQuery webroot folder i created custom.js
$(document).ready(function(){ $("#hide").click(function(){ $("p").hide(); }); });
In sight I
<?php
echo $this->Html->css('index');
echo $this->Html->script('custom');
?>
<p ><?php echo "some text"; ?></p>
<?php echo $this->Form->button('click me',array('id'=>'hide'));?>
+3
user4294557
source
to share
1 answer
Say the path to custom.js file in webroot / js / jquery / custom.js then you can view it with
<?php echo $this->Html->script('jquery/custom.js'); ?>
If the path is not in the webroot / js folder (say webroot / jquery / custom.js), include the entire file path, for example
<?php echo $this->Html->script('/jquery/custom.js'); ?>
Always add the line below at the end as described here
echo $this->Js->writeBuffer();
+1
source to share