Thursday, January 19, 2012

How to cunfigure JQuery with Zend 1.11


1- In bootstrap add this function:

   protected function _initAppAutoload() {
        $moduleLoader = new Zend_Application_Module_Autoloader(array(
                    'namespace' => '',
                    'basePath' => APPLICATION_PATH));

        $this->bootstrap('view');
        $view = $this->getResource('view');
    $view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
   
    $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
    $viewRenderer->setView($view);
    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
    $view->dojo()->enable();
    }


2- download JQuery and put the folder inside public/js.

3- add this lines below to application.ini :
resources.view[] =
pluginPaths.ZendX_Application_Resource_ = "ZendX/Application/Resource"
resources.jquery.localpath = "/js/jquery-ui-1.8.17.custom/js/jquery-1.7.1.min.js"
resources.jquery.stylesheet = "/js/jquery-ui-1.8.17.custom/css/pepper-grinder/jquery-ui-1.8.17.custom.css"
resources.jquery.uilocalpath = "/js/jquery-ui-1.8.17.custom/js/jquery-ui-1.8.17.custom.min.js"


4- finally put these lines in <head> inside your layout.phtml:
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <?php echo $this->headTitle(); ?>
        <?php  echo $this->headLink()->appendStylesheet('/css/style.css'); ?>
        <?php echo $this->headLink(); ?>
        <?php echo $this->jQuery(); ?> 

    </head>


for testing put this code to index.phtml :
<form method="post" action="/hello/world">
Pick your Date: <?php echo $this->datePicker("dp1",
                                             '',
                                             array(
                                                'defaultDate' =>
                                                    date('Y/m/d', time())));?>
<input type="submit" value="Submit" />
</form>


that`s it .