You can include whatever JS you need like this:
http://book.cakephp.org/view/1589/script
its pretty straightforward. Just add in the script in either the
layout ctp or the view. Bit of fiddling about to make sure jquery is
added before the jquery dependent plugin and you are off.
if you are adding code you want just outputted to the page you can do
something like this:
$a = "
$(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();
$(\".open\").trigger('click');
});
";
$this->Js->buffer($a);
in your view, and then in the bottom of the layout.ctp file, output
the buffer like this:
echo $this->Js->writeBuffer();
make sure you do that below your echo $scripts_for_layout so you
don't fall over jquery dependency.
hth
On Jan 30, 4:40 pm, tubiz <[email protected]> wrote:
> Please as many web designers will say Jquery is one of the most
> popular Javascript framwework. But the problem i am having is how to
> implement jquery in my cake apps.
> Is is in the view i will import the jquery source and how do i write
> custom jquery code to target specific section of my site like a form
> ("that will be created using the Form Helper") and is it possible to
> use to jquery autocomplete plugin on my site.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php