On Thursday 27 Jan 2011 01:34:05 Xian Chen wrote:
> Hi All,
>
> I am new to Zend framework and try jquery functions.
>
> I setup jquery headers and css files.
>
> To run datepicker, I put the following code in index.phtml
> <form>
> <?php echo $this->datePicker('dp3',' ',array()); ?>
> </form>
>
> It works as expected.
>
> But, if I put those code in layout.phtml, I get only a blank text box, no
> date picker object at all.
>
> Any comments for that?
>
> thanks,
> Xian
This piece of code injects some javascript into the jQuery view helper at the
top of your layout. Because view scripts [1] are rendered earlier than
layouts, this works. View rendered -> Code injected into view helper -> Layout
rendered -> Javascript placed.
When you place the code in your layout, the view helper doesn't have the
javascript yet while it's rendered and then the datepicker is placed.
So layout rendered -> no javascript placed (it's empty) -> datepicker placed.
You need the view script or use the placeholder view helper to render the
datepicker first.
Regards, Jurian
[1] Actually a layout is a view, but in this case I mean view scripts as views
for action controllers.
--
Jurian Sluiman
Soflomo - http://soflomo.com