Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Weetos on Oct 15, 2009 13:34
open dhtmlx forum
Create a dhtmlXWindow if it doesn't exist yet

Hey there

I've set up a nice way to display a map on a site using dhtmlXWindow, but I'm experiencing an annoying issue :

I have four links on the page that are meant to open a map, showing different locations, in a dhtmlXWindow using attachURL.
Currently, each time the user clicks on one of those links, a new dhtmlXWindow opens showing the corresponding map, even if there was one or more already opened. The user can't tell because I use a fixed position and move/resize are disabled, but there can a whole pile of maps hidden beneath the one that is visible.

What I'd like is this :
User clicks on one of the links : if no dhtmlXWindow exists yet, then one is created, displaying the requested map. Then if the user clicks another link without closing the existing one, the requested map is being displayed in the existing dhtmlXWindow.

I tried to set this up but my limited js skills prevent me from doing it right

Any help would be greatly appreciated on how to achieve this result.

Thanks
Answer posted by Alex (support) on Oct 16, 2009 01:23

Hello,

you can try to use dhxWins.window(winId) to check if window exists or not:

dhxWins = new dhtmlXWindows();

...
var win = null
function openWindow(url){
 if(!dhxWins.window("w1"))
    win = dhxWins.createWindow("w1", 20, 30, 320, 240);
 dhxWins.window("w1").attachURL(url);
}

Answer posted on Oct 17, 2009 04:50
Works like a charm !

Thanks you so much !