2009年4月23日星期四

[fw-mvc] Dojo dijit undefined error

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". What
did I miss or do wrong? Many thanks for advices in advance.

In the View:

<?php
$this->dojo()->enable()
->setDjConfigOption('parseOnLoad', true);

$this->dojo()->javascriptCaptureStart();
?>
function test() {
alert(dijit.byId("id"));
}
<?php
$this->dojo()->javascriptCaptureEnd();

$this->dojo()->onLoadCaptureStart();
?>
alert(dijit.byId("id"));
<?php
$this->dojo()->onLoadCaptureEnd();

echo $this->form;
?>

In the Form:

$this->addElement(
...
array(
'onchange' => 'test()',
)
);

没有评论: