Re: Jquery Help
First, you'll want to include the jQuery library in the head of your page. I do it on my default layout using the following code: /app/views/layouts/default.ctp echo $html->script('https://ajax.googleapis.com/ajax/libs/jquery/1.4/ jquery.min.js'); This is hosted via google but of course, you can always link to a copy that you download and save in the /app/webroot/js/ folder: echo $html->script( 'jquery.min' ); For the page-specific jquery code, I usually save common code together in a file and save it in the /app/webroot/js/ folder and link to it in whichever view needs it: /app/views/controller/your_view.ctp echo $html->css('jquery_file', null, array('inline'=>false)); By specifying inline=>false, it forces the script to be output in the $scripts_for_layout variable in my default layout. To use jQuery, you can simply call selectors as you would with any HTML document. Submitting form data to the controller via ajax might look like this: /app/webroot/js/jquery_file.js $(document).ready(function(){ $('#YourButtonID').click(function(){ $('#YourFormId').submit(); }); }); I'm most comfortable creating my own jQuery, so the example above isn't very cake-esque. You should look into the JsHelper to work within Cake's guidelines. If you do that, remember to include the following code right before you close the body tag: /app/views/layouts/default.ctp echo $this->Js->writeBuffer(); This outputs all the javascript that you create in your views, etc. Good luck. On Jan 29, 9:40 pm, tubiz 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Jquery Help
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 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: jQuery help
I can see you are using ".save_me" as the selector but then your link should have class="save_me", other wise $('.save_me') wont find any elements. Try link('yourtext', '#', array(..., 'class' => 'save_me')); ?> To output the controller/action url you can use url ('/controller_name/action_name'); ?> Good luck, hope this helps --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---