I am having similar problems when trying to do something like this:
<?php $this->dojo()->onLoadCaptureStart(); ?>
function(){
dojo.connect(dijit.byId(<my-dijit-id>), 'onClick', myfunction());
}
<?php $this->dojo()->onLoadCaptureEnd(): ?>
The dojo.connect doesn't work because when the page is rendered, my
dojo.addOnLoad statment is added before the bit that is generated by the
Zend_Dojo view helper.
Shouldn't the default behavior of the onLoadCaptureStart method be to append
rather than prepend?
Erik
Drew Bertola wrote:
>
> Matthew Weier O'Phinney wrote:
>> -- 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/ *
> -------------------------------------------------
>
>
>
--
View this message in context: http://www.nabble.com/Can%27t-manipulate-the-Dojo-addOnLoad-queue-tp21222936p21492948.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论