2008年12月30日星期二

[fw-mvc] Can't manipulate the Dojo addOnLoad queue

Hi everyone,

I'm trying to manipulate the order of the addOnLoad queue for the
Zend_Dojo container. I need to be able to manipulate the DOM after
dojo.parser.parse() is called (so that my dijits are available).

Unfortunately, the only way I can do this is a bit clumsy. I've tried
using:

$view->dojo()->addOnLoad("my.whatever.someFunc()");

but this renders backwards (for my needs) as:

dojo.addOnLoad(my.whatever.someFunc());
dojo.addOnLoad(function() {
dojo.forEach(zendDijits, function(info) {
var n = dojo.byId(info.id);
if (null != n) {
dojo.attr(n, dojo.mixin({ id: info.id }, info.params));
}
});
dojo.parser.parse();

and since someFunc() is trying to manipulate dijits, and the dijits are not yet created by parse(), I get javascript errors.

I can work around this with:

$view->dojo()->addJavascript("dojo.addOnLoad(function(){my.whatever.someFunc();});");

but, at best, that's ... clumsy.

Any ideas?

--
Drew Bertola

-------------------------------------------------
* PHP/LAMP Consultant, ZCE-1000 *
* *
* Tel: 408-966-6671 *
* *
* current resume: *
* http://drewb.com/blog/about/resume/ *
-------------------------------------------------

没有评论: