ZF-7357: dojo is not work when i use it in one action not the defualt indexAction() , the error: the dojo.js is nto defined!

Issue Type: Bug Created: 2009-07-23T01:31:07.000+0000 Last Updated: 2009-07-23T04:35:37.000+0000 Status: Resolved Fix version(s): Reporter: yao junqiang (hack_yjq) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Dojo

Related issues: Attachments:


first step, I make a dir named "js" in the public directory, I copy the dojo library in the dir "js" second step, in the Bootstrap.php protected function _initDoctype() { $this->bootstrap('view'); $view = $this->getResource('view'); $view->doctype('XHTML1_TRANSITIONAL'); $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); }

3th step, in the layout.phtml

dojo()->isEnabled()){ $this->dojo()->setLocalPath('js/dojo/dojo.js') ->addStyleSheetModule('dijit.themes.tundra'); echo $this->dojo(); } ?> forth step, A controler named UserControler.php , there is a loginAction() ,in the login.phtml view file, dojo()->enable() ->setDjConfigOption('parseOnLoad', true) ->setDjConfigOption('isDebug', true) ->requireModule(''); ?> if i request , , the problem will come , " dojo.js is not defined!"



Posted by Matthew Weier O'Phinney (matthew) on 2009-07-23T04:35:10.000+0000

The first problem is where you call setLocalPath(). Prefix it with either a '/' or with the base URL to your application (which should also include a '/' at the beginning):

<pre class="highlight">

// or
$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
$this->dojo()->setLocalPath($baseUrl . '/js/dojo/dojo.js');

If you don't have the leading slash, then it will look for js/dojo/dojo.js relative to the current url -- so, in your example, '/user/login/js/dojo/dojo.js', instead of '/js/dojo/dojo.js' which is what you really want.

The second problem: Don't check for "if ($this->dojo()->isEnabled())" in your view script. Do your Dojo setup in your bootstrap, and selectively enable it within your various view scripts. In your layout, just call 'dojo() ?>' -- which will render it if enabled, and do nothing if not enabled.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.