1

I am rather new to ZendX and I really wanted to get the simple JQuery example on Zend to get working.I have followed the example on the link below but all I get is a plain textbox without any datepicker functionality as I expected.

Best way to start using jQuery in a Zend Framework 1.9 application?

In my bootstrap I have

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

In my layout I have included

<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>

What am I missing?

Community
  • 1
  • 1
davykiash
  • 1,796
  • 5
  • 27
  • 60

3 Answers3

0

i go through application.ini way which works out like this:

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"

I am not sure about bootstrap code but what I got from research is the below code. May be the last three lines will help.

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);                                            
}  
000
  • 3,976
  • 4
  • 25
  • 39
0
  1. Did you call the view helper from within your view script, with valid options? See example from your refered question

  2. Did you double check the paths to your local js- & css-files?

chelmertz
  • 20,399
  • 5
  • 40
  • 46
  • That is the solution I used to do my example but to no avail.Sorry I forgot to specific that link earlier.As for the local files I have cross checked and the paths and they are correct. – davykiash Jan 13 '10 at 12:42
0

You add ZendX_JQuery::enableView($view); to _initViewHelpers

Can Aydoğan
  • 1,040
  • 2
  • 10
  • 23