-- Innocentus <[email protected]> wrote (on Friday, 03 April 2009, 11:39 PM +0200): > I have a custom view helper which adds tooltips to a view. > JavaScript is needed for these tooltips so I need to add an external > JavaScript-file. > This I want to do when the view helper is called the first time - > because otherwise it is unnecessary. > Because I want to add more than only one tooltip I need to prevent > that this JavaScript-file is added multiple times. > > The JavaScript-file responsible for the tooltips should be added only > when the tooltip view helper is called and this only once. > Successive calls of the view helper shouldn't result in adding the > JavaScript-file multiple times. > > Now I don't know if there is already a mechanism for custom > view-helpers for doing so. > Maybe there is already something I could rely on.
Take a look at the placeholders, and how the Dojo and jQuery view helpers work, as they give you exactly this type of functionality. What I would suggest is using the headScript() view helper within your custom view helper, as headScript() also has this built into its functionality. -- Matthew Weier O'Phinney Software Architect | [email protected] Zend Framework | http://framework.zend.com/
