Re: adding additional jquery functionality on cake 1.3
Thanks a bunch! I read through the code snippet but haven't tried it yet. But I think this gives me a lot closer than anything else I've found on the web. I was hoping that there would be a way to utilize the Js helper rather than output to $scripts_for_layout. Thanks, though--this gives me a good start! On Fri, Jul 23, 2010 at 10:54 AM, cricket wrote: > On Fri, Jul 23, 2010 at 3:13 AM, Jon Chin wrote: > > I followed the tutorial for getting Jquery set up on Cake 1.3, but now > I'm > > having trouble getting Jquery plugins to work. I haven't been able to > find > > any webpages or tutorials for this, so I'm asking here. I think what I > need > > to do is somehow get the code for the plugin to get added to the buffer > and > > in the $(document).ready function. Maybe extend the jquery_engine? I'm > not > > sure how to do it, so can anybody steer me in the right direction? > Thanks! > > In what sense is it not working? When you view source, do you see > script tags for the plugin(s)? If so, is the path correct? How are you > trying to include them? In the layout? View? Show some code; perhaps > you have an error there. > > As for adding things to $(document).ready() note that jquery can > handle multiple calls to that. IOW, you can have a ready() block in > your global.js, your admin.js, in one or more script blocks in the > head, etc. So, let's say you want to add a WYSIWYG editor to some > view. You can include the necessary plugin from the view as well as a > JS block with the plugin's init code inside another call to > $(document).ready(). > > layout: > echo $html->script('lib/jquery-1.4.1.min'); > echo $html->script('global'); > echo $scripts_for_layout; > > view: > echo $this->element('wysiwyg', array('selectors' => > array('#PageContent'), 'upload_path' => '/uploads')); > > element: > $html->css('jwysiwyg/jquery.wysiwyg', 'stylesheet', > array('media'=>'screen,projector', 'inline' => false)); > echo $html->script('lib/jquery.form.min', false); > echo $html->script('lib/jquery.wysiwyg', false); > echo $html->script('editor', false); > > $code = '$(function() { '; > foreach($selectors as $selector) > { >if (empty($upload_path)) $upload_path = null; >$code .= "initEditor('${selector}', '${upload_path}');\n"; > } > $code .= '});'; > $html->scriptBlock($code, array('inline' => false)); > > The scriptBlock method will add a new call to ready() (I'm using a > slightly different jquery syntax here) into $scripts_for_layout. > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: adding additional jquery functionality on cake 1.3
On Fri, Jul 23, 2010 at 3:13 AM, Jon Chin wrote: > I followed the tutorial for getting Jquery set up on Cake 1.3, but now I'm > having trouble getting Jquery plugins to work. I haven't been able to find > any webpages or tutorials for this, so I'm asking here. I think what I need > to do is somehow get the code for the plugin to get added to the buffer and > in the $(document).ready function. Maybe extend the jquery_engine? I'm not > sure how to do it, so can anybody steer me in the right direction? Thanks! In what sense is it not working? When you view source, do you see script tags for the plugin(s)? If so, is the path correct? How are you trying to include them? In the layout? View? Show some code; perhaps you have an error there. As for adding things to $(document).ready() note that jquery can handle multiple calls to that. IOW, you can have a ready() block in your global.js, your admin.js, in one or more script blocks in the head, etc. So, let's say you want to add a WYSIWYG editor to some view. You can include the necessary plugin from the view as well as a JS block with the plugin's init code inside another call to $(document).ready(). layout: echo $html->script('lib/jquery-1.4.1.min'); echo $html->script('global'); echo $scripts_for_layout; view: echo $this->element('wysiwyg', array('selectors' => array('#PageContent'), 'upload_path' => '/uploads')); element: $html->css('jwysiwyg/jquery.wysiwyg', 'stylesheet', array('media'=>'screen,projector', 'inline' => false)); echo $html->script('lib/jquery.form.min', false); echo $html->script('lib/jquery.wysiwyg', false); echo $html->script('editor', false); $code = '$(function() { '; foreach($selectors as $selector) { if (empty($upload_path)) $upload_path = null; $code .= "initEditor('${selector}', '${upload_path}');\n"; } $code .= '});'; $html->scriptBlock($code, array('inline' => false)); The scriptBlock method will add a new call to ready() (I'm using a slightly different jquery syntax here) into $scripts_for_layout. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: adding additional jquery functionality on cake 1.3
I dont know what exactly you want, but maybe this can help you http://snipt.net/chrisyour/cakephp-content_for-capture-html-block-for-layout/ Its the content_for function of rails for cake, its very useful to add content to the head of the layout or maybe other thinks to the layout itself --- Norman Paniagua 2010/7/23 Jon Chin > I followed the tutorial for getting Jquery set up on Cake 1.3, but now I'm > having trouble getting Jquery plugins to work. I haven't been able to find > any webpages or tutorials for this, so I'm asking here. I think what I need > to do is somehow get the code for the plugin to get added to the buffer and > in the $(document).ready function. Maybe extend the jquery_engine? I'm not > sure how to do it, so can anybody steer me in the right direction? Thanks! > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
adding additional jquery functionality on cake 1.3
I followed the tutorial for getting Jquery set up on Cake 1.3, but now I'm having trouble getting Jquery plugins to work. I haven't been able to find any webpages or tutorials for this, so I'm asking here. I think what I need to do is somehow get the code for the plugin to get added to the buffer and in the $(document).ready function. Maybe extend the jquery_engine? I'm not sure how to do it, so can anybody steer me in the right direction? Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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