Actually, I meant to use a "return" statement like so:
function init() {
var domNode = document.getElementById("form1:dropDown1");
if (domNode == null || typeof domNode.subscribe !=
"function") {
return setTimeout('init();', 10);
}
domNode.subscribe(domNode.event.refresh.endTopic,
processEvents, "update");
}
If your alerts are not being executed, it may be that you have the wrong id.
Dan
Ryan de Laplante wrote:
> The init function was causing hundreds of "dojo.event has no
> properties" errors. I think you intended for the subscribe to be in
> an else block, so I changed it to look like this:
>
> function init() {
> var domNode = document.getElementById('form1:dropDown1');
> if (domNode == null || domNode.event == null) {
> setTimeout("init();", 10);
> } else {
> alert('before subscribe');
> domNode.subscribe(domNode.event.refresh.endTopic,
> processEvents, "update");
> alert('after subscribe');
> }
> }
>
> I never see the alerts because it seems that domNode.event always ==
> null.
>
> Thanks,
> Ryan
>
>
> Dan Labrecque wrote:
>> When are you calling the document.getElementById function? I suspect
>> you're calling this too early and the widget has not been created,
>> yet. In Woodstock 4.3 (next milestone), I've added an onLoad
>> attribute to the head tag. This will ensure your function is executed
>> after all widgets have been initialized. In the mean time, you can
>> use the approach below.
>>
>> <head>
>> <script type="text/javascript">
>> var processEvents = {
>> update: function(props) {
>>
>> document.getElementById('form1:progressBar1').setProps({"visible":false});
>>
>> }
>> }
>> function init() {
>> var domNode = document.getElementById("form1:dropDown1");
>> if (domNode == null || domNode.event == null) {
>> setTimeout("init();", 10);
>> }
>> domNode.subscribe(domNode.event.refresh.endTopic,
>> processEvents, "update");
>> }
>> </script>
>> </head>
>> <body onload="init();">
>> ...
>>
>> Dan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_woodstock.dev.java.net
> For additional commands, e-mail: users-help_at_woodstock.dev.java.net
>