更新:这个问题指的是 Zend Framework 的旧版本。要了解如何将 jQuery 与 Zend Framework 1.9.4 (1.8+) 应用程序集成,请参阅此问题。
我想我了解基本概念,但我一定是在某个地方出错了。我正在尝试将 jQuery、jQuery UI 和 jQuery 主题集成到我的 Zend Framework 应用程序中。
在我的引导程序中,我正在注册 jQuery 视图助手:
$view->addHelperPath(self::$root . '/library/ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');
在我的表单中,我有一个日期选择器元素:
$date = new ZendX_JQuery_Form_Element_DatePicker('date');
在我的布局中,我调用了 jQuery 视图助手:
<head>
<?= $this->jQuery() ?>
</head>
完成此操作后,我实际上可以使用日期选择器。唯一的问题是日历完全搞砸了。它根本无法正确显示。
据我了解,javascript 文件是自动包含的(并由 Google 托管)。因此,为了使用不同的主题(来自ThemeRoller),您必须在自己的服务器上托管 js 和 css 文件。为了让我的日期选择器显示不同的主题,我应该经历什么过程?
更新:我通过这样做让它工作。但我不确定这是否是最有效的方法。
<head>
<? //I couldn't get this way to work
//$this->jQuery()->addStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7/themes/smoothness/jquery-ui.css');
//But this way works
$this->jQuery()->addStylesheet('/js/jquery/themes/ui-lightness/jquery-ui-1.7.1.custom.css')
->setLocalPath('/js/jquery/js/jquery-1.3.2.min.js')
->setUiLocalPath('/js/jquery/js/jquery-ui-1.7.1.custom.min.js') ?>
<?= $this->jQuery() ?>
</head>