【发布时间】:2012-01-03 17:21:27
【问题描述】:
我正在使用以下代码来实现一些 jquery-ui 功能:
<?php $this->Html->script(array(
'jquery-ui-1.8.16.custom.min.js',
'jquery-1.6.2.min.js'
),
null,
array(
'inline'=>'false',
'once'=>'true'
)
);
?>
<script>
jQuery(document).ready(function(){
$('.cv .collapsable').click(function() {
$(this).next().toggle('slow');
return false;
}).next().hide();
});
</script>
目标元素/类是一个元素和嵌套元素。然而,jquery 功能正在工作,但代价是 php array_merge() 错误,如下所示:
Warning (2): array_merge() [function.array-merge]: Argument #2 is not an array [CORE/Cake/View/Helper/HtmlHelper.php, line 478]
Warning (2): array_merge() [function.array-merge]: Argument #2 is not an array [CORE/Cake/View/Helper/HtmlHelper.php, line 478]
Warning (2): array_merge() [function.array-merge]: Argument #2 is not an array [CORE/Cake/View/Helper/HtmlHelper.php, line 478]
我做错了吗?这是一个错误吗?我尝试将 <script> 标签添加到 default.ctp 布局,但也无法使 URL 正常工作。我已经用 cakephp 1.3 完成了这个,所以我对我现在遇到的问题有点困惑。任何帮助将不胜感激。
更新
这是我的完整代码: PHP:
<?php $this->Html->script(
array(
'jquery-1.6.2.min'
),
null,
array(
'inline'=>'false',
)
); ?>
jquery:
<script>
jQuery(document).ready(function() {
$('div.collapsable').click(function() {
$(this).next().slideToggle("slow");
return false;
});
});
</script>
我已经删除了 jquery-ui 脚本来简化事情——当我这样做时,我现在只会抛出两个“array_merge”错误。尽管如此,如果我删除“null”——它甚至不应该存在,因为该函数只接受两个参数——我会失去所有功能(错误也会消失)。
但是事情变得更奇怪了!
我查看了 cake->core->lib->helper->htmlhelper 并检查了函数;它有一行检查$options 数组是否为布尔值。如果我改为使用此代码:
<?php $this->Html->script(
array(
'jquery-1.6.2.min'
),
false
); ?>
我失去了指定inline = true 或once = true 的能力,但是我至少获得了完整的功能而没有array_merge() 错误。这是 2.0 的错误吗?
【问题讨论】:
标签: cakephp html-helper cakephp-2.0