users@woodstock.java.net

Re: dojo endTopic events

From: Ryan de Laplante <ryan_at_ijws.com>
Date: Mon, 09 Jun 2008 09:45:29 -0400

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