Domanda

Sto lottando per costruire una semplice applicazione Zend Framework che può chiamare jQuery. Allora, che cosa sto lavorando sotto Zend Studio 7.1.1 in cui ho aggiunto, nella cartella della libreria, la cartella "ZendX". E, ho scaricato anche la leggerezza tema jQuery che è stato aggiunto alla cartella pubblica "js".

Troverete l'intera struttura è come quella: http://www.freeimagehosting.net/image.php?b95bca6dab.png Quindi quello che ho fatto è: 1- aggiunte le righe seguenti nel file bootstrap.php modo che ho ottenuto il seguente contenuto:

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

Poi, come io non uso i layout, ho aggiunto direttamente il DatePicker nel file index.phtml con la $view->jQuery() e $view->jQuery() anche se quando digito $view-> il sistema intellisense Zend Studio non propone la funzione jQuery(). In ogni caso, il file 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>

<?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/">Zend Framework Website</a> |
            <a href="http://framework.zend.com/manual/en/">Zend Framework Manual</a>
        </p>
    </div>
</div>

Ma non funziona nulla!

ottengo il seguente output:

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

Come si può vedere, il testo di input DatePicker è qui, ma sullo scatto, si vede nulla.

E per la pagina di origine (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/">Zend Framework Website</a> |
            <a href="http://framework.zend.com/manual/en/">Zend Framework Manual</a> 
        </p> 
    </div> 
</div>

Ho cercato molte combinaisons, ma c'è modo di capire che! Se cercato anche di trovare un video che mostra esattamente, passo dopo passo, come integrare jQuery in Zend.

Cosa c'è di sbagliato nel codice?

Se potete aiutarmi, vorrei davvero apprezzare questo!

Grazie mille,

saluti.

È stato utile?

Soluzione

<?php $this->jQuery->enable;?> opportuno enable() e risiedono nel controllore / bootstrap.


Se vuoi aggiungere jQuery per tutte le pagine, vorrei cambiare

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

a

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

, altrimenti non è necessario per consentire a tutti, dal momento che chiamare un aiutante come datePicker() inclues automaticamente jQuery e jQuery UI sulla tua pagina.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top