问题
What do I use in the controller to append a javascript file to the end of a view?
I do not want to put it in the head, so headScript() and headLink() are out, but I cannot find a working example of what I'm looking for in either the Zend documentation or elsewhere.
I've tried using $this->inlineScript()->appendFile('/js/myfile.js');, but it throws an error saying inlineScript() doesn't exist. I'm assuming its Zend 2 only.
Can someone point me in the right direction to a method that does what I'm asking for, or does it (oddly) not exist?
回答1:
Try that:
$this->view->InlineScript()->appendFile($this->view->baseUrl() .'/js/myfile.js');
and in the bottom of youy layout add:
<?php
echo $this->InlineScript();
?>
来源:https://stackoverflow.com/questions/22842010/zend-1-12-append-javascript-to-bottom-of-view