cakephp - cakePHP 2 中的 javascript 助手发生了什么变化?

标签 cakephp cakephp-2.0 cakephp-2.1

我用过这个 item并收到此错误:

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 {
 }
确实,这个文件不存在,我试图在我的辅助数组中使用“Js”。
class myClassController expend AppController {
    var $helpers = array('Html', 'Js'); // and not 'Javascript');
在代码中,方法$this->Javascript->codeBlock被调用以添加一个 javascript 方法(在内容的中间而不是标题中),但也没有 $this->Js->codeBlockcodeBlock 。
$output .= $this->Js->codeBlock("datepick('" . $htmlAttributes['id'] . "','01/01/" . $options['minYear'] . "','31/12/" . $options['maxYear'] . "');");
    
你能解释一下旧的 Javascript 助手发生了什么或者如何让代码工作吗?
还有其他可以与 CakePHP-2.0 一起使用的助手吗?
亲切地,

最佳答案

你读过迁移指南吗?如果现在不这样做:
http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html#xmlhelper-ajaxhelper-and-javascripthelper-removed

XmlHelper, AjaxHelper and JavascriptHelper removed The AjaxHelper and JavascriptHelper have been removed as they were deprecated in version 1.3. The XmlHelper was removed, as it was made obsolete and redundant with the improvements to Xml. The Xml class should be used to replace previous usage of XmlHelper.

The AjaxHelper, and JavascriptHelper are replaced with the JsHelper and HtmlHelper.

JsHelper JsBaseEngineHelper is now abstract, you will need to implement all the methods that previously generated errors.



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

就是现在
$this->Html->codeBlock('...');

关于cakephp - cakePHP 2 中的 javascript 助手发生了什么变化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12051234/

相关文章:

mysql - 为什么我的 find 子句不起作用?

php - CakePHP:创建新的 HABTM 行而不是更新其他行

cakephp - 如何从 Controller 传递简单数据以在cakePHP中进行查看

mysql - Cakephp 具有多个字段的搜索选项

php - 在 cakephp 2.4.6 中,只有两个页面将 HTTP 重定向到 HTTPS,最好的方法是 ht-access 或 Cakephp Security Companent

php - 将 utf8 unicode 字符串转换为 PHP 中的 uft8 general ci 而不是来自 MySQL

file-upload - 不使用插件的简单cakephp 2.0上传

mysql - CakePHP 2 - 一个表的两个外键链接到同一个表主键

javascript - 在 Windows 中加载 WePay Embedded Checkout IFrame 时出错

css - 有没有办法跟踪我在 cakephp 中调用的 css 文件?