views:

451

answers:

1

Hi everybody,

I'm struggling to build a simple zend framework application that can call jQuery. So, what I'm working under Zend Studio 7.1.1 where I added, in the library folder, the "ZendX" folder. And, I also downloaded the jQuery lightness theme that was added to the "js" public folder.

You'll find the whole structure is like that: http://www.freeimagehosting.net/image.php?b95bca6dab.png So what I did is: 1- Added the following lines into the Bootstrap.php file so that I obtained the following content:

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{


}
Zend_Loader::registerAutoload();
$view= new Zend_View();
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
$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');

Then, as I don't use the layouts, I directly added the datepicker in the index.phtml file with the $view->jQuery() and $view->jQuery() even if when I type $view-> the Zend Studio intellisense system doesn't propose the jQuery() function. Anyway, the index.phtml file is:

<style>
    a:link,
    a:visited
    {
        color: #0398CA;
    }

    span#zf-name
    {
        color: #91BE3F;
    }

    div#welcome
    {
        color: #FFFFFF;
        background-image: url(http://framework.zend.com/images/bkg_header.jpg);
        width:  600px;
        height: 400px;
        border: 2px solid #444444;
        overflow: hidden;
        text-align: center;
    }

    div#more-information
    {
        background-image: url(http://framework.zend.com/images/bkg_body-bottom.gif);
        height: 100%;
    }
</style>
<div id="welcome">
    <h1>Welcome to the <span id="zf-name">Zend Framework!</span></h1>

    <h3>This is your project's main page</h3>

<?php echo $this->headScript(); ?>
<?php echo $this->jQuery()->uiEnable();?>
<?php echo $this->jQuery(); ?>
<form id='ok'>
Pick your Date: <?php echo $this->datePicker('dp1', '', array('defaultDate' => date('Y/m/d', time()))); ?>
</form>
    <div id="more-information">
        <p><img src="http://framework.zend.com/images/PoweredBy_ZF_4LightBG.png" /></p>
        <p>
            Helpful Links: <br />
            <a href="http://framework.zend.com/"&gt;Zend Framework Website</a> |
            <a href="http://framework.zend.com/manual/en/"&gt;Zend Framework Manual</a>
        </p>
    </div>
</div>

But nothing works!

I get the following output:

ttp://www.freeimagehosting.net/uploads/7ed0166140.png

As you can see, the datepicker input text is here, but on click, it shows nothing.

And for the source page (index.phtml):

<style> 
    a:link,
    a:visited
    {
        color: #0398CA;
    }

    span#zf-name
    {
        color: #91BE3F;
    }

    div#welcome
    {
        color: #FFFFFF;
        background-image: url(http://framework.zend.com/images/bkg_header.jpg);
        width:  600px;
        height: 400px;
        border: 2px solid #444444;
        overflow: hidden;
        text-align: center;
    }

    div#more-information
    {
        background-image: url(http://framework.zend.com/images/bkg_body-bottom.gif);
        height: 100%;
    }
</style> 
<div id="welcome"> 
    <h1>Welcome to the <span id="zf-name">Zend Framework!</span></h1> 

    <h3>This is your project's main page</h3> 


<link rel="stylesheet" href="../public/js/jquery/css/ui-lightness/jquery-ui-1.7.2.custom.css" type="text/css" media="screen"> 

<script type="text/javascript" src="../public/js/jquery/js/jquery-1.3.2.min.js"></script> 
<script type="text/javascript" src="../public/js/jquery/js/jquery-ui-1.7.2.custom.min.js"></script> 

<form id='ok'> 
Pick your Date: <input type="text" name="dp1" id="dp1" value=""></form> 
    <div id="more-information"> 
        <p><img src="http://framework.zend.com/images/PoweredBy_ZF_4LightBG.png" /></p> 
        <p> 
            Helpful Links: <br /> 
            <a href="http://framework.zend.com/"&gt;Zend Framework Website</a> |
            <a href="http://framework.zend.com/manual/en/"&gt;Zend Framework Manual</a> 
        </p> 
    </div> 
</div>

I really tried many combinaisons, but no way to figure out it! If also tried to find a video showing exactly, step by step, how to integrate jQuery in Zend.

What's wrong in the code?

If you can help me, I would really appreciate that!

Thanks very much,

regards.

A: 

<?php $this->jQuery->enable;?> should be enable() and reside in the controller/bootstrap.


If you'd like to add jQuery to all pages, I would change

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

to

$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')
    ->enable()
    ->enableUi();

, otherwise you don't need to enable it at all, since calling a helper like datePicker() automatically inclues jQuery and jQuery UI on your page.

chelmertz
Thanks for your instructions. As you see, I updated the topic so that in take in consideration your changes. Now, it includes the CSS and JS files with the good path, but the datepicker doesn't appear and, with the Firefox error console, no errors raise. So good includes, but nothing works.Regards.
Zakaria
I uploaded my full project with the Zend and ZendX libraries at this location: http://jump.fm/ABPFJTo download, just go to the "Save file to your pc" area.Regards
Zakaria
nobody can help me please?
Zakaria