I've never used blockEnd() and don't quite understand its purpose, but codeBlock should take the javascript (as a string) for the first param. It will wrap the code with start/stop tags.
On Wed, May 20, 2009 at 6:53 AM, Miki <[email protected]> wrote: > > Hi all, > > I'm a not very experimented user. I'm trying to use jQuery in Cake > (based on > http://bakery.cakephp.org/articles/view/serving-up-actions-as-ajax-with-jquery-in-a-few-simple-steps). > > When I tried to use the codeBlock and endBlock functions I have > unexpected results. > > My code in the view: > > echo $javascript->link('jquery-1.3.1.min.js',false); > echo $javascript->link('jquery.form.js',false); > echo $javascript->codeBlock(null, array('inline' => false)); > ?> > $(document).ready(function() { > var options = { > target:'#elementsList' // target element(s) to be updated > with server response > }; > > // bind form using 'ajaxForm' > $('#newElementForm').ajaxForm(options); > }); > <?php > echo $javascript->blockEnd(); > ?> > > I have shown that the blockEnd always print the end script tag to the > html (inline is not running well). > > I look the Cake code and change it (first time) adding this in the > blockEnd. I think that it fix the bug (if it is a bug): > > //existing code > if (isset($options['inline']) && !$options['inline']) { > $view =& ClassRegistry::getObject('view'); > //new code > if ($safe) { > $script = "\n" . '//<![CDATA[' . "\n" . > $script; > $script = $script . "\n" . '//]]>' . "\n"; > } > //existing code > > $view->addScript(sprintf($this->tags['javascriptblock'], $script)); > //new code > return null; > } > > I hope it helps. > > Miki > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
