Both Dojo and Woodstock widgets are created during the window.onLoad
event. This was a change that Dojo forced upon us when upgrading to Dojo
.9, back for 4.1 build #14. On the plus side, it allows for progressive
rendering of HTML.
Although you're code may have used dojo.addOnLoad, there is no guarantee
that your code will be invoked last. (Other code, including Woodstcok
widgets also use this function.) I've found that it is safer to test if
a widget exists before invoking APIs. (I see you have used similar
code.) For example:
<head>
<script type="text/javascript">
function init() {
var domNode = document.getElementById('form1:fc1');
if (domNode == null || typeof domNode.setChooseButton !=
"function") {
return setTimeout('init();', 10);
}
domNode.setChooseButton('form1:button1');
}
</script>
</head>
<body onLoad="init();">
Note that a similar example exists in the Woodstock release notes.
Dan
Ryan Burrows wrote:
> Hi,
>
> I am currently trying to update an application I am working on to use
> 4.1.1 from a previous build, and I've noticed that functions that I've
> added to the page via dojo.addOnLoad() are sometimes being fired
> before all of the elements on the page are loaded. For example:
>
> dojo.addOnLoad(
> function () {
> var charCount = $('textArea').getProps().value.length;
> $('staticText').setProps({ value : charCount.toString() });
> }
> );
>
> in a <w:script> tag at the end of the page will cause a javascript
> error saying "$('textArea') has no properties" when the page is
> loaded. The way I have found to fix this is by changing the above
> call to the below:
>
> dojo.addOnLoad(
> function init() {
> if ($('textArea') && $('staticText')) {
> var charCount = $('textArea').getProps().value.length;
> $('staticText').setProps({ value : charCount.toString() });
> } else {
> setTimeout(init, 5);
> }
> }
> );
>
> Before updating to 4.1.1 this worked with the initial function. Is
> there some other function that dojo.addOnLoad() that I can use to
> ensure that the entire page has been built?
>
> Thanks,
> Ryan Burrows
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_woodstock.dev.java.net
> For additional commands, e-mail: users-help_at_woodstock.dev.java.net
>
>