views:

37

answers:

1

How to have Dojo support disabled by default and just enable it if you want to use it ?

I have the problem that dojo support is automaticly loaded when using any form. Even without any dojo elements.

I have following configuration:

Bootstrap file

    if($this->dojo()->isEnabled()){

$this->dojo()->setLocalPath($this->baseUrl().'/js/dojo/dojo/dojo.js') ->addStyleSheetModule('dijit.themes.tundra') ->setDjConfigOption('usePlainJson',true); echo $this->dojo();}

I thought to enable dojo I had to use explicit use something like this in my template/view file:

 $this->dojo()->enable();

How the tell Zend Framework not to use Dojo by default for Forms ?

+1  A: 
<?php
  if ($this->dojo()->isEnabled())
  {
   $this->dojo()
                    ...
   echo $this->dojo();
  }
 ?>

Prints the the javascript required to enable dojo if it is enabled. I tend to put this in my layout script,.

I add the dojo as a view helper in the bootstrap inside _initViewHelpers()

$view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');

Then enable as required in the controller

 $this->view->dojo()->enable();

If you use a standard Zend_Form with no Dojo elements Dojo shouldn't be loaded.

piddl0r