我是ZendX的新手,我真的想在Zend上获得简单的JQuery示例才能正常工作。我已经按照下面链接中的示例进行了操作,但我得到的是一个没有任何datepicker功能的纯文本框,正如我所料。
Best way to start using jQuery in a Zend Framework 1.9 application?
在我的训练中,我有
protected function _initViewHelpers()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->doctype('XHTML1_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$view->headTitle()->setSeparator(' - ');
$view->headTitle('JQUERY Test');
//assuming you already have this function in your bootstrap
//jQuery (using the ui-lightness theme)
$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');
}
在我的布局中,我已经包含了
<head>
<?php echo $this->HeadMeta(); ?>
<?php echo $this->headTitle(); ?>
<?php echo $this->headLink(); ?>
<?php echo $this->headScript(); ?>
<?php echo $this->jQuery(); ?>
<?php echo $this->headLink()->prependStylesheet($this->baseUrl().'/css/main.css'); ?>
<?php echo $this->render('_javascript.phtml'); ?>
</head>
我错过了什么?
答案 0 :(得分:0)
您是否从中调用过视图助手? 在您的视图脚本中,使用有效选项?请参阅示例 来自你提到的问题
您是否仔细检查了当地js-&amp;的路径? CSS-文件?
答案 1 :(得分:0)
您将ZendX_JQuery::enableView($view);
添加到_initViewHelpers
答案 2 :(得分:0)
我通过application.ini方式运行如下:
resources.view.helperPath.ZendX_JQuery_View_Helper = "ZendX/JQuery/View/Helper"
resources.view[] =
pluginPaths.ZendX_Application_Resource = "ZendX/Application/Resource"
resources.jquery.localpath = "/project1/public/jquery/development-bundle/jquery-1.7.1.js"
resources.jquery.stylesheet = "/project1/public/jquery/development-bundle/themes/smoothness/jquery-ui-1.8.18.custom.css"
resources.jquery.uilocalpath = "/project1/public/jquery/development-bundle/ui/jquery-ui-1.8.18.custom.js"
我不确定bootstrap代码,但我从研究中得到的是下面的代码。可能是最后三行会有所帮助。
protected function _initViewHelpers()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->doctype('XHTML1_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$view->headTitle()->setSeparator(' - ');
$view->headTitle('JQUERY Test');
//assuming you already have this function in your bootstrap
//jQuery (using the ui-lightness theme)
$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');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
}