> -- Drew Bertola <drew@drewb.com> wrote
> (on Tuesday, 30 December 2008, 04:54 PM -0800):
>
>> I've now refined this to:
>>
>> ->addJavascript('dojo.addOnLoad(my.init);')
>>
>> Which is slightly better... but still feels clumsy.
>>
>
> I can't remember the rest of the thread... but why aren't you using
> addOnLoad()?
>
> $view->dojo()->addOnLoad('function(){my.whatever.someFunc()};');
>
> or
>
> $view->dojo()->addOnLoad('my.init');
>
> ?
[sorry, this reply originally didn't make it to the list]
OK, so the problem with using $view->dojo()->addOnLoad('my.init'); is
that the dijits for my form elements don't exist in the DOM at the time
of my.init() being called (and I want to mess with the dijits just a
bit). What happens is that the way the addOnLoad queue is built, my
addOnLoads would come before the ones that ZF produces in the dojo form
container view helper. So, dojo.parser.parse() gets called late in the
addOnLoad queue, rather than earlier (before my.init()).
It ends up rendering like this:
dojo.addOnLoad('my.init()');
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();
});
but I need the dojo.addOnLoad('my.init()') after the dijits are parsed.
That's why I can work around it with addJavascript(). It follows the
addOnLoad()s in the rendering order.
--
Drew Bertola
-------------------------------------------------
* PHP/LAMP Consultant, ZCE-1000 *
* *
* Tel: 408-966-6671 *
* *
* current resume: *
* http://drewb.com/blog/about/resume/ *
-------------------------------------------------
没有评论:
发表评论