Zend 1.12: Append javascript to bottom of view

ε祈祈猫儿з 提交于 2019-12-10 09:37:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!