Zend 1.12:将javascript附加到视图的底部 [英] Zend 1.12: Append javascript to bottom of view

查看:90
本文介绍了Zend 1.12:将javascript附加到视图的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在控制器中使用什么来将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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆