Show/hide multi DHTMLX window

Hi,

I’ve got 3 kind of DHTMLX window in my page (w2,w3,w4) with diferents size and functions for each windows.

It works well when I open/close the same kind of window but for example if I open w2 and close it and after open a w3 or w4 I have a blank page…

I use this :

function openInWindow(url) {
if (!dhxWins) dhxWins = new dhtmlXWindows();
if (!dhxWins.window(“w2”)) {
dhxWins.enableAutoViewport(false);
dhxWins.setSkin(“dhx_web”);
dhxWins.attachViewportTo(“winVP”);
dhxWins.setImagePath(“tools/dhtmlxwindows/codebase/imgs/”);
var w2 = dhxWins.createWindow(“w2”, 20, 30, 800, 300);
w2.setModal(true);
w2.setText(" ");
w2.center();
w2.clearIcon();
w2.denyResize();
w2.button(“minmax1”).hide();
w2.button(“park”).hide();
w2.denyMove();
w2.denyPark();
w2.attachEvent(“onClose”, function(win){
if (win.getId() == “w2”) {
LoadDiv(‘force’);
win.setModal(false);
win.hide();
}
});
} else {
var w2 = dhxWins.window(“w2”);
//w2.setSkin(“dhx_web”);
w2.setModal(true);
w2.show();
}
w2.attachURL(url);
};

function openInFullText(obj,txtorigin,txtnew) {
if (!dhxWins) dhxWins = new dhtmlXWindows();
if (!dhxWins.window(“w3”)) {
dhxWins.enableAutoViewport(false);
dhxWins.setSkin(“dhx_web”);
dhxWins.attachViewportTo(“winVP”);
dhxWins.setImagePath(“tools/dhtmlxwindows/codebase/imgs/”);
var w3 = dhxWins.createWindow(“w3”, 20, 30, 900, 700);
w3.setModal(true);
w3.setText(" ");
w3.center();
w3.clearIcon();
w3.denyResize();
w3.button(“minmax1”).hide();
w3.button(“park”).hide();
w3.denyMove();
w3.denyPark();
w3.attachEvent(“onClose”, function(win){
if (win.getId() == “w3”) {
win.setModal(false);
win.hide();
}
});
} else {
var w3 = dhxWins.window(“w3”);
w3.setModal(true);
w3.show();
}
document.getElementById(txtnew).value=(document.getElementById(txtorigin).value);
w3.attachObject(obj);
};

function replaceText(txtorigin,txtnew){
document.getElementById(txtorigin).value=(document.getElementById(txtnew).value);
dhxWins.window(“w3”).close();
};

function openFlux(url) {
if (!dhxWins) dhxWins = new dhtmlXWindows();
if (!dhxWins.window(“w4”)) {
dhxWins.enableAutoViewport(false);
dhxWins.setSkin(“dhx_web”);
dhxWins.attachViewportTo(“winVP”);
dhxWins.setImagePath(“tools/dhtmlxwindows/codebase/imgs/”);
var w4 = dhxWins.createWindow(“w4”, 10, 10, 315, 750);
w4.setModal(true);
w4.setText(" ");
w4.center();
w4.clearIcon();
w4.denyResize();
w4.button(“minmax1”).hide();
w4.button(“park”).hide();
w4.denyMove();
w4.denyPark();
w4.attachEvent(“onClose”, function(win){
if (win.getId() == “w4”) {
win.setModal(false);
win.hide();
}
});
} else {
var w4 = dhxWins.window(“w4”);
w4.setModal(true);
w4.show();
}
w4.attachURL(url);
};

Thanks for your help.

Hi,

could you attach the complete demo ? docs.dhtmlx.com/doku.php?id=othe … leted_demo

hi,

I’ve just find the problem, i have to declare separate var like this (before functions) :

var dhxWins2;
var dhxWins3;
var dhxWins4;

And use it after in the functions :

function openInWindow(url) {
if (!dhxWins2){ dhxWins2 = new dhtmlXWindows();
alert(‘create 2’);
}
if (!dhxWins2.window(“w2”)) {
alert(‘attach 2’);
dhxWins2.enableAutoViewport(false);
dhxWins2.setSkin(“dhx_web”);
dhxWins2.attachViewportTo(“winVP”);
dhxWins2.setImagePath(“tools/dhtmlxwindows/codebase/imgs/”);
var w2 = dhxWins2.createWindow(“w2”, 20, 30, 800, 300);
w2.setModal(true);
w2.setText(" ");
w2.center();
w2.clearIcon();
w2.denyResize();
w2.button(“minmax1”).hide();
w2.button(“park”).hide();
w2.denyMove();
w2.denyPark();
w2.attachEvent(“onClose”, function(win){
if (win.getId() == “w2”) {
LoadDiv(‘force’);
win.setModal(false);
win.hide();
}
});
} else {
alert(‘show 2’);
var w2 = dhxWins2.window(“w2”);
w2.setModal(true);
w2.show();
}
w2.attachURL(url);
};

function openInFullText(obj,txtorigin,txtnew) {
if (!dhxWins3){ dhxWins3 = new dhtmlXWindows();
alert(‘create 3’);
}
if (!dhxWins3.window(“w3”)) {
alert(‘attach 3’);
dhxWins3.enableAutoViewport(false);
dhxWins3.setSkin(“dhx_web”);
dhxWins3.attachViewportTo(“winVP”);
dhxWins3.setImagePath(“tools/dhtmlxwindows/codebase/imgs/”);
var w3 = dhxWins3.createWindow(“w3”, 20, 30, 900, 700);
w3.setModal(true);
w3.setText(" ");
w3.center();
w3.clearIcon();
w3.denyResize();
w3.button(“minmax1”).hide();
w3.button(“park”).hide();
w3.denyMove();
w3.denyPark();
w3.attachEvent(“onClose”, function(win){
if (win.getId() == “w3”) {
win.setModal(false);
win.hide();
}
});
} else {
alert(‘show 3’);
var w3 = dhxWins3.window(“w3”);
//w3.setSkin(“dhx_web”);
w3.setModal(true);
w3.show();
}
document.getElementById(txtnew).value=(document.getElementById(txtorigin).value);
w3.attachObject(obj);
};

function openFlux(url) {
if (!dhxWins4) dhxWins4 = new dhtmlXWindows();
if (!dhxWins4.window(“w4”)) {
dhxWins4.enableAutoViewport(false);
dhxWins4.setSkin(“dhx_web”);
dhxWins4.attachViewportTo(“winVP”);
dhxWins4.setImagePath(“tools/dhtmlxwindows/codebase/imgs/”);
var w4 = dhxWins4.createWindow(“w4”, 10, 10, 315, 750);
w4.setModal(true);
w4.setText(" ");
w4.center();
w4.clearIcon();
w4.denyResize();
w4.button(“minmax1”).hide();
w4.button(“park”).hide();
w4.denyMove();
w4.denyPark();
w4.attachEvent(“onClose”, function(win){
if (win.getId() == “w4”) {
win.setModal(false);
win.hide();
}
});
} else {
var w4 = dhxWins4.window(“w4”);
w4.setModal(true);
w4.show();
}
w4.attachURL(url);
};

Thank you and sorry to ask you to early (i spent a long time searching)