Javascript – dojo dijit dialog underlay not showing

dojojavascript

I'm trying to have three different dialogs on as hidden initially, then depending on the response from the ajax form submit, i wish to show different dialogs.

When the form is submitted and waiting for the response, i can show the "in progress" dialog.
Then if the server returns an error response, I want to hide the first dialog, then display another dialog depending on the error response type.

I can almost achieve what I want to do except when I hide the first dialog and show the next one, the underlay disappears.
If then I scroll inside the browser window, the underlay is displayed properly.
I'm doing something simple like this:

dijit.byId("progress_dialog").hide();
dijit.byId("error_dialog").show();

Anyone have suggestions?

I've seen the following page on dojo website, but it seems to be an interim solution for dojo 0.9?
http://www.dojotoolkit.org/forum/dijit-dijit-0-9/dijit-support/showing-dialog-right-after-hiding-another-dialog-while-keeping-u

any help would be appreciated.

Thanks.

[Edit]
okay, I've "solved" the issue by adding a little delay like below.

dijit.byId("progress_dialog").hide();
setTimeout(function() {
    dijit.byId("error_dialog").show();
    }, 500);

This works for me, but I think there could be a better way of solving it.
Any takers?

[Edit again]
The version I'm working with is dojo-1.3.2

Best Answer

There appeared a lot of issues with dialogs' underlay in dojo 1.3 because all dialog objects started to use 1 common underlay object (instead of creating their own underlay).
I suspect the underlay in your case is shown before it gets hidden - you can debug if you wish ;)
As a workaround a timeout is ok(it can be less, I guess). Or you can try to connect to hide method (however not sure this will help):

dojo.connect(dijit.byId("progress_dialog"), "hide", dijit.byId("error_dialog"), "show");
dijit.byId("progress_dialog").hide();

But taking into account all those issues with underlay in 1.3, I would consider using dojo 1.4, as some patches for dijit.Dialog have been committed: http://docs.dojocampus.org/releasenotes/1.4.

Related Topic