我有一些JavaScript代码需要包含在视图中,我使用了inkedmn在此线程中提供的方法:adding-page-specific-javascript-to-each-view-in-cakephp
因此,现在我的视图中有以下代码:
$this->set('jsIncludes',array('google')); // this will link to /js/google.js
但我需要将一些值从视图传递到JavaScript文件中,我不确定如何实现这一点。
更新:我猜一个选项是在php文件中回显这些值,用div标签括起来,然后在JavaScript代码中使用getElementById()。