Zend Framework 的视图助手中需要 dojo.require 吗?

发布于 2024-09-28 01:09:37 字数 735 浏览 0 评论 0原文

我尝试过使用 Dojo 按钮视图助手,但 Zend 似乎不会自动生成 dojo.require('dijit.form.Button')。这是正确的行为吗?

以下是我的布局脚本的摘录:

<head>
    <?= $this->dojo()->setDjConfigOption('usePlainJson',true)->addStylesheetModule('dijit.themes.claro')->setLocalPath("/js/dojo/dojo.js"); ?>
</head>
...
<?= $this->button('test', 'test') ?>

这是在我的引导程序中:

public function _initDojo() {
    $view = $this->getResource('view');
    $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
    Zend_Dojo::enableView($view);
    Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
}

dojo.require 之外,所有其他特定于 Dojo 的代码均已正确呈现。

I've tried using a Dojo button view helper, but it appears that Zend will not automatically generate a dojo.require('dijit.form.Button'). Is this correct behavior?

Here's excerpt from my layout script:

<head>
    <?= $this->dojo()->setDjConfigOption('usePlainJson',true)->addStylesheetModule('dijit.themes.claro')->setLocalPath("/js/dojo/dojo.js"); ?>
</head>
...
<?= $this->button('test', 'test') ?>

And this is in my bootstrap:

public function _initDojo() {
    $view = $this->getResource('view');
    $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
    Zend_Dojo::enableView($view);
    Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
}

All other Dojo-specific code is rendered properly, except the dojo.require.

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

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

发布评论

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

评论(1

深巷少女 2024-10-05 01:09:37

我没有单独使用 dijit 助手,所以我只能为您提供部分答案。

当您在 Zend_Dojo_Form 中使用 dijit 元素时,ZF 肯定会自动添加适当的需求。从帮助程序代码来看,当您单独使用它们时,似乎也会发生这种情况。

如果您真的像示例中那样在 layout 中调用 $this->button ,那么我猜它不起作用只是因为 dojo 助手已经运行了呼叫您的助手的时间。您可以尝试将相同的调用移至视图脚本,看看这是否可以解决问题(视图脚本在布局之前呈现)。

I've not used the dijit helpers on their own so I only have a partial answer for you.

ZF definitely automatically adds the appropriate requires when you use dijit elements in Zend_Dojo_Form. From looking at the helper code it looks like this should happen when you use them on their own as well.

If you are really calling $this->button in your layout as in your example, then I would guess that it's not working simply because the dojo helper has already run by the time your helper is called. You could try moving the same call to a view script instead to see if this solves the problem (view scripts are rendered before layouts).

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