2010-01-13 36 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);            
}