2009年4月23日星期四

Re: [fw-mvc] Dojo dijit undefined error

2009/4/23 Kostyantyn Shakhov <kshakhov@gmail.com>
I'm tying the code below. When the test() JS function is called by an
"onchange" event everything works as intended and dijit.byId is
defined but I get the error  "dijit is undefined" for "onload".
 
$this->dojo()->onLoadCaptureStart();
?>
alert(dijit.byId("id"));
<?php
$this->dojo()->onLoadCaptureEnd();
 
$this->addElement(
...
array(
'onchange' => 'test()',
)
);

Dojo addOnLoad hooks should be run after the parsing of dijits. However, maybe you're creating the element programmatically and not declaratively (it means with a function passed to addOnLoad that pulls the dom id and create the dijit over it, and not with a dojoType attribute). So my hypothesis is that maybe you add the element after doing capturing, and the dijit creation code goes after the alert. You can guess by looking at the html source in the head tag.

--
Giorgio Sironi
Piccolo Principe & Ossigeno Scripter
http://ossigeno.sourceforge.net

没有评论: