【问题标题】:ZendX date picker example not workingZendX 日期选择器示例不工作
【发布时间】:2010-01-13 07:25:18
【问题描述】:

我对 ZendX 还很陌生,我真的很想在 Zend 上使用简单的 JQuery 示例来开始工作。我已经按照下面链接中的示例进行操作,但我得到的只是一个纯文本框,没有我预期的任何日期选择器功能。

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>

我错过了什么?

【问题讨论】:

    标签: zend-framework jquery-ui zendx


    【解决方案1】:
    1. 您是否从 在您的视图脚本中,具有有效选项?见example from your refered question

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

    【讨论】:

    • 这是我用来做示例的解决方案,但无济于事。抱歉,我之前忘记具体说明该链接。至于本地文件,我已经交叉检查过,路径和它们是正确的。
    【解决方案2】:

    您将ZendX_JQuery::enableView($view); 添加到_initViewHelpers

    【讨论】:

      【解决方案3】:

      我通过 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);                                            
      }  
      

      【讨论】:

        猜你喜欢
        • 2014-07-21
        • 2021-12-14
        • 2017-12-24
        • 2016-06-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多