-- derek fong <[EMAIL PROTECTED]> wrote
(on Thursday, 31 July 2008, 02:47 PM -0400):
> Looks like I spoke too soon.  :(  The reason it worked for me before was
> because I still had another call to the same helper in my controller, which is
> what was actually causing the headScript call to work as expected, but since
> removing that from my controller, headScript will still not output the
> JavaScript to the head of my document.
> 
> I forgot to mention, if it makes a difference, that my custom helper extends
> the Zend_View_Helper_FormTextarea...

Can you:

  * Post the complete helper code where the call to headScript() is
    made, and

  * Post the code that invokes the helper, and

  * Indicate if you are using Zend_Layout, and whether the helper is
    being invoked in the layout script or one of your application view
    scripts. Please send your layout script as well.

Now, that said...

If you set items in headScript() in your layout script _after_ echoing
headScript(), then you've got a basic chicken and egg syndrome -- your
ducks are not in a row. Otherwise, it's likely something more subtle.

> On 31 Jul 2008, at 14:10, derek fong wrote:
> 
> 
>     Excellent, thanks!  Worked like a charm.  =)
> 
>     -f-
> 
>     On 31 Jul 2008, at 13:52, Taco Jung wrote:
> 
> 
>         Hi,
> 
>         Use the following function in your custom view helper to get the 
> global
>         view:
> 
>         public function setView(Zend_View_Interface $view){
> 
>          $this->view = $view;
> 
>         }
> 
>         Then using $this->view->headScript() in your helper will work.
> 
>         Regards, TJ.
> 
>         On Thu, Jul 31, 2008 at 7:41 PM, derek fong <[EMAIL PROTECTED]>
>         wrote:
> 
>             Hi,
> 
>             I have a custom view helper from which I'd like to inject some 
> code
>             into the head of my page using the Zend_View_Helper_HeadScript
>             helper.  I have the following code in my custom helper:
> 
>             if (!$this->init) {
>                $this->view->headScript()->appendFile('/assets/js/tree.js');
>             }
> 
>             However, while the script successfully gets injected into the head
>             of my document when called from my controller, it does *not* work
>             if I call the helper from the view.  I'm pretty sure I'm just
>             missing something obvious here..  Can anyone help out with this?
> 
>             Thanks,
> 
>             -f-
> 
> 
>             --
>             Derek Fong
>             Web Application Developer
>             subtitle designs inc. <http://www.subtitled.com/>
> 
>             "Mistakes are the portals of discovery." --James Joyce
>                >> GPG key/fingerprint available upon request <<
> 
> 
> 
> 
> 
> 
> 

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to