Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by SFGolfer on Jun 24, 2009 06:39
open dhtmlx forum
dhtmlxWindows with dhtmlxAccordion - Content not appearing on window reopen

I'm having an issue with dhtmlxWindows embedded with dhtmlxAccordion.

The content appears within the accordion just fine when the window is first opened. However, upon closing the window and re-opening it, the content within the accordion is blank.

======================================================
<html>
<head>
<title>Test</title>

<script src="../codebase/dhtmlxcommon.js"></script>

<link rel="stylesheet" type="text/css" href="../../dhtmlxwindows/codebase/dhtmlxwindows.css">
<link rel="stylesheet" type="text/css" href="../../dhtmlxwindows/codebase/skins/dhtmlxwindows_dhx_blue.css">
<script src="../../dhtmlxwindows/codebase/dhtmlxwindows.js"></script>

<script src="../../dhtmlxaccordion/codebase/dhtmlxaccordion.js"></script>
<link rel="stylesheet" type="text/css" href="../../dhtmlxaccordion/codebase/skins/dhtmlxaccordion_dhx_blue.css">

</head>
<body>

<a href="#" onclick="showWindow()">Show Window</a>

<script>
function showWindow(){

var dhxWins = new dhtmlXWindows();
dhxWins.setImagePath("../../dhtmlxwindows/codebase/imgs/");
dhxWins.setSkin("dhx_blue");

var w1 = dhxWins.createWindow("w1", 20, 10, 350, 275);
w1.center();
w1.setText("Help Window");
w1.allowResize();
w1.button("close").enable();
w1.button("minmax1").hide();
w1.button("park").hide();
w1.isOnTop(true);

var dhxAccord = w1.attachAccordion();
dhxAccord.setIconsPath("../../dhtmlxaccordion/codebase/imgs/");
dhxAccord.addItem("a1", "Features");
dhxAccord.addItem("b1", "Quick Tips");
dhxAccord.addItem("c1", "FAQs");
dhxAccord.openItem("a1");

dhxAccord.cells("a1").attachObject("a1");
dhxAccord.cells("b1").attachObject("b1");
dhxAccord.cells("c1").attachObject("c1");

}
</script>

<div id="a1" style="display:none;">Features here</div>
<div id="b1" style="display:none;">Quick Tips here</div>
<div id="c1" style="display:none;">FAQs here</div>

</body>
</html>
Answer posted by Alex (support) on Jun 24, 2009 07:05

Hello,

this is correct behavior. When attachObject method is called, the object is moved into the accordion cell. And after you close window, it's removed.

One of the possible solutions is to call  code from showWindow() only once ( in order to create window). The logic of the close button can be changed, so the window will be hiden instead of closed. And in this case in order to show window again you can call only w1.show(). This solution allows to improve performance as the window object will be created only once:

w1.btns["close"]._doOnClick = function() {w1.hide()}

function showWindow(){

  w1.show();

}