2010-01-13 34 views
1

我对ZendX很新,我真的想在Zend上得到简单的JQuery示例以获得工作。我在下面的链接上遵循了该示例,但我得到的是纯文本框,没有任何datepicker功能如我所料。ZendX日期选择器示例不起作用

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
  1. 你叫从 视图助手视图脚本中,与有效的选项?请参阅example from your refered question

  2. 您是否仔细检查了本地js- & css文件的路径?

+0

这就是我用来做我的例子中,解决方案,但没有avail.Sorry我忘了具体的,对于本地文件我已经交叉检查和路径链接earlier.As,他们是正确的。 – davykiash

0

你加ZendX_JQuery::enableView($view);到_initViewHelpers

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" 

我不知道关于引导代码,但我从研究得到的是下面的代码。可能是最后三条线会有所帮助。

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);            
}