views:

13

answers:

1

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.

A: 

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).

Tim Fountain