Zend 1.12:将javascript附加到视图的底部 [英] Zend 1.12: Append javascript to bottom of view
问题描述
我在控制器中使用什么来将javascript文件附加到视图的末尾?
What do I use in the controller to append a javascript file to the end of a view?
我不想把它放在头部,所以 headScript()
和 headLink()
已经出局,但我找不到我正在寻找的工作示例Zend文档或其他地方。
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.
我尝试使用 $ this-> inlineScript() - > appendFile('/ js / myfile.js');
,但它会抛出错误,说明 inlineScript()
不存在。我只假设它的Zend 2.
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?
推荐答案
试试:
$this->view->InlineScript()->appendFile($this->view->baseUrl() .'/js/myfile.js');
并在你的布局底部添加:
and in the bottom of youy layout add:
<?php
echo $this->InlineScript();
?>
这篇关于Zend 1.12:将javascript附加到视图的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!