Comments

  1. Hi Ryan

    yes, I can never remember the syntax for this off the top of my head! (and the CSS equivalent). What I often do is to make the code more redable, put the Javascript statement in a heredoc syntax in PHP

    e.g

    $js = <<<MYJS

    /* all this is javascript */
    var foo = bar;

    // etc

    MYJS;

    so then you can just popo the $js variable in the cake codeBlock() call.

    I find web developing easier if I can keep things clean and ordered like this.

    Anything really long should pretty much go in an external javascript file, named consistently – so much design is just good conventions I realise…

    August 24, 2009 at 5:02 am |
  2. Ryan,
    if you use (the default)
    array(“inline” => false)
    then $javascript->codeBlock() is returning the codeblock, but not echoing it. Thus you need to add an “echo” in front of it.

    codeBlock(‘window.addEvent(“domready”, alert(“hi there 2”));’); ?>
    works fine in your view.

    Regards,
    Kalileo

    December 23, 2009 at 10:09 am |
  3. hmmm, and it has eaten the
    echo $form-> in front of it too :s
    let’s try again:

    echo $form->codeBlock(‘window.addEvent(“domready”, alert(“hi there″));’);

    December 23, 2009 at 10:24 am |
  4. echo $form->codeBlock(‘window.addEvent(“domready”, alert(“hi there″));’);

    Should be

    echo $javascript->codeBlock(‘window.addEvent(“domready”, alert(“hi there″));’);

    January 22, 2010 at 8:00 pm |

Leave a Reply

You must be logged in to post a comment.