Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by aspi on Aug 12, 2008 08:59
open dhtmlx forum
shtmlXWindow

This component is Super!

I have a question, how can i close modal window from attached html or php document?

or attached document conatin button <input type="button" onclick='close.modalwindow('w1')>
Answer posted by Support on Aug 12, 2008 09:45
If you are using attachURL , you can access parent window and call related method as 

            <input type="button" onclick="parent.dhxWins.window('w1').close();">

where
- dhxWins - name of window controller in parent windows
- w1 - name of window which need to be closed

Answer posted by Piramidon on Feb 28, 2009 21:47

Hi,

What if I am using attachObject in situation like that, how can I close modal window by clicking a button inside attached DIV?

Thank you.

Answer posted by Alex (support) on Mar 02, 2009 08:44

Hi,

in this case the approach is simpler - just call close() method for window object. For example:

<input type="button" value="close window" onclick="w1.close();">

Answer posted by Piramidon on Mar 02, 2009 11:21

Check my code please:

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

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

</head>

<body onLoad="javascript:showModalWindow();">

<div id="myMessageBox" style="font-family: Tahoma; font-size: 10pt; overflow: auto; visibility: hidden;" align="center"><br><br><br><input type="button" value="Close" onClick="w1.close();"></div>


<script>

 function showModalWindow() {

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

  var w1 = dhxWins.createWindow("w1", 10, 10, 320, 240);
  w1.setText("System Message");
  w1.button("close").enable();
  w1.button("minmax1").disable();
  w1.button("park").disable();

  dhxWins.window('w1').center();
  dhxWins.window('w1').denyMove();
  dhxWins.window('w1').denyResize();
  dhxWins.window('w1').setModal(true);

  dhxWins.window('w1').attachObject(myMessageBox);
  myMessageBox.style.visibility="visible";

  };

 </script>
</body>
</html>

I've got 'w1' is undefined javascript error. What is wrong?

Thank you.

Answer posted by Alex (support) on Mar 03, 2009 02:46

Hello,

There is a JavaScript issue in your code - w1 is a private variable. The following will work correctly:

var w1;

function showModalWindow() {

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

w1 = dhxWins.createWindow("w1", 10, 10, 320, 240);
...

}