Reputation: 839
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?
Upvotes: 3
Views: 1535
Reputation: 5772
Try that:
$this->view->InlineScript()->appendFile($this->view->baseUrl() .'/js/myfile.js');
and in the bottom of youy layout add:
<?php
echo $this->InlineScript();
?>
Upvotes: 3