I am creating a custom zend form element that will require some javascript. I can add the javascript I need like this:
/**
* Renders the javascript to the view.
*/
protected function _generateJavaScript()
{
$this->view->headScript()->captureStart(); ?>
$(document).ready(function(){
alert('hello');
});
<?php $this->view->headScript()->captureEnd();
}
However, if this custom form element is used multiple times, the identical javascript will appear multiple times. Is there a way to only render the javascript once?