在 Zend Framework 1.9 应用程序中开始使用 jQuery 的最佳方式? [英] Best way to start using jQuery in a Zend Framework 1.9 application?

查看:18
本文介绍了在 Zend Framework 1.9 应用程序中开始使用 jQuery 的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始在我的 Zend Framework 应用程序中使用 jQuery,但不确定哪种是最好的开始方式.我知道我可以像其他任何 javascript 库一样包含 jQuery 库,但是使用 ZendX_JQuery 有什么优势,以及在我的 Zend Framework 1.9 应用程序中开始使用它的必要步骤是什么?

I want to get started working with jQuery in my Zend Framework application but not sure which is the best way to get started. I know I could include the jQuery library just like any other javascript library, but what are the advantages of using ZendX_JQuery, and what are the steps necessary to start using it in my Zend Framework 1.9 application?

推荐答案

通过执行以下步骤,我能够让 jQuery 在我的 1.9.4 项目中工作:

I was able to get jQuery working in my 1.9.4 project by following these steps:

步骤 1:将 ZendX 目录复制到您的 library 目录.ZendX 可以在您的 Zend Framework 下载的 extras/library 目录中找到.

Step 1: Copy the ZendX directory to your library directory. ZendX can be found in the extras/library directory of your Zend Framework download.

第 2 步:从 jqueryui.com 下载 jQuery 和 jQuery UI 库.我选择了 UI Lightness 主题.

Step 2: Download jQuery and the jQuery UI library from jqueryui.com. I chose the UI Lightness theme.

第 3 步:解压下载并将 jquery-ui-1.7.2 重命名为 jquery 并移动到您的 public/js 目录.

Step 3: Extract the download and rename jquery-ui-1.7.2 to jquery and move to your public/js directory.

第 4 步:将这些行添加到您的 bootstrap 文件中:

Step 4: Add these lines to your bootstrap file:

protected function _initViewHelpers()
{
    $view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
    $view->jQuery()->addStylesheet('/js/jquery/css/ui-lightness/jquery-ui-1.7.2.custom.css')
        ->setLocalPath('/js/jquery/js/jquery-1.3.2.min.js')
        ->setUiLocalPath('/js/jquery/js/jquery-ui-1.7.2.custom.min.js');
}

第 5 步:现在将 jQuery 视图助手添加到您的 layout 文件:

Step 5: Now add the jQuery view helper to your layout file:

<head>
    <?php echo $this->jQuery(); ?>
</head>

第 6 步:要测试您是否一切正常,请将此行添加到您的一个视图脚本:

Step 6: To test that you have everything working, add this line to one of your view scripts:

Pick your Date: <?php echo $this->datePicker("dp1", '', array('defaultDate' => date('Y/m/d', time()))); ?>

现在,如果您在浏览器中打开此页面,应该会有一个文本字段.您应该能够点击文本字段,它会自动弹出一个日历,该日历的样式已设置为 UI Lightness 主题.

Now, if you open this page in your browser, there should be a text field. You should be able to click on the text field, which automatically pops up a calendar that has been styled to the UI Lightness theme.

这篇关于在 Zend Framework 1.9 应用程序中开始使用 jQuery 的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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