设置cakephp以使用JQuery [英] Setting up cakephp to use JQuery

查看:83
本文介绍了设置cakephp以使用JQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近遇到了CakePhp作为一个优秀的框架,我目前正在移植我的网站蛋糕。在使用JQuery方面,目前推荐的包含javascript /访问javascript文件的方法是什么。做一点挖掘,有些人建议app / config中心位置......你们都有什么想法?

I've recently come across CakePhp as an excellent framework and am currently porting over my site to cake. In terms of using JQuery, what is the currently recommended method for including the javascript / accessing the javascript files. Doing a little digging, some people have suggested a central place in app/config ... what do you all think?

谢谢。

推荐答案

将包含jquery的javascript文件添加到 / app / webroot / js /

Add your javascript files including jquery to /app/webroot/js/.

然后在您的布局上( / app / views /layouts/default.ctp ),只需使用javascript助手加载你的javascript文件。

Then on your layout (/app/views/layouts/default.ctp), just use the javascript helper to load your javascript files.

<head>
<title><?php echo $title_for_layout; ?></title>
<?php echo $javascript->link('jquery'); ?>
...
</head>

确保您的应用加载了javascript助手。在您的 app_controller.php 或单个控制器上。

Make sure javascript helper is loaded on your app. Either on your app_controller.php or individual controllers.

var $ helpers = array( 'Html','Form','Javascript');

这篇关于设置cakephp以使用JQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆