What happened to the javascript helper in cakePHP 2?

I used this element and got this error:

Missing Helper
Error: JavascriptHelper could not be found.
Error: Create the class JavascriptHelper below in file: app/View/Helper/JavascriptHelper.php
<?php
     class JavascriptHelper extends AppHelper {
 }

Well, really, this file does not exist, and I tried to use "Js" in my auxiliary array.

class myClassController expend AppController {
    var $helpers = array('Html', 'Js'); // and not 'Javascript');

In the code, the method $this->Javascript->codeBlockis called to add the javascript method (in the middle of the contents instead of the header), but $ this-> Js-> codeBlockcodeBlock does not exist.

$output .= $this->Js->codeBlock("datepick('" . $htmlAttributes['id'] . "','01/01/" . $options['minYear'] . "','31/12/" . $options['maxYear'] . "');");

Could you explain to me what happened to the old Javascript helper or how to make the code work?

Is there any other helper that can work with CakePHP-2.0?

Cordially,

+5
source share
2 answers

? : http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html#xmlhelper-ajaxhelper-and-javascripthelper-removed

XmlHelper, AjaxHelper JavascriptHelper AjaxHelper JavascriptHelper , 1.3. XmlHelper , Xml. Xml XmlHelper.

AjaxHelper JavascriptHelper JsHelper HtmlHelper.

JsHelper JsBaseEngineHelper , , .

So

$this->Js->codeBlock('...');

$this->Html->codeBlock('...');
+8
HtmlHelper::scriptBlock($code, $options = array())
    //Parameters:   

    $code (string) – The code to go in the script tag.
    $options (array) – An array of html attributes.
0

All Articles