Zend Framework appendFile 在 jQuery 包含后不起作用

发布于 2024-08-27 04:08:59 字数 481 浏览 3 评论 0原文

我正在布局中设置 jQuery 的本地路径。然后使用appendFile添加另一个js文件,但它没有添加我要附加的文件。

在布局中:

$jquery=$this->jQuery();
$jquery->enable(); // enable jQuery Core Library
$jquery->setLocalPath($this->baseUrl().'/js/jquery-1.3.2.min.js');
echo $jquery;
echo $this->headScript();

在我看来:

$this->headScript()->appendFile($this->baseUrl().'/js/jquery.corner.js');

感谢您的帮助

I'm setting a local path for jQuery in my layout. Then adding another js file using appendFile, but it's not adding the file I'm appending.

in layout:

$jquery=$this->jQuery();
$jquery->enable(); // enable jQuery Core Library
$jquery->setLocalPath($this->baseUrl().'/js/jquery-1.3.2.min.js');
echo $jquery;
echo $this->headScript();

In my view:

$this->headScript()->appendFile($this->baseUrl().'/js/jquery.corner.js');

thanks for any help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等数载,海棠开 2024-09-03 04:08:59

您需要将以下行放入您的操作中,而不是您的视图中:

$this->view->headScript()->appendFile($this->view->baseUrl().'/js/jquery.corner.js');

echo $this->headScript(); 行在您的任何视图代码之前执行,因此它不会'不要考虑您的 appendFile() 语句。如果将其放入操作中,则在渲染布局和视图之前会调用操作代码,因此它将考虑到它。

You need to put the following line in your action, instead of your view:

$this->view->headScript()->appendFile($this->view->baseUrl().'/js/jquery.corner.js');

The line echo $this->headScript(); is being executed before any of your view code is, so it won't take your appendFile() statement into account. If you put it in your action, the action code is called before the layout and view are rendered, so it will take it into account.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文