EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: essco on October 10, 2014, 05:44:47 PM



Title: Closing a Window
Post by: essco on October 10, 2014, 05:44:47 PM
Gentlepersons...

I have a window in which I open another window consisting of a particular web page.  When I click on the button to "close" the web page the window stays open.  How does the child program "tell" the parent program to close himself(the child)?

Charlie


Title: Re: Closing a Window
Post by: stworthy on October 10, 2014, 06:36:43 PM
When clicking the 'close' button on the window header, the 'onClose' event fires, in which you can call 'close' method to close another window.
Code:
$('#w2').window({
onClose: function(){
$('#w1').window('close')
}
})


Title: Re: Closing a Window
Post by: essco on October 10, 2014, 07:46:40 PM
Thank you much for your reply... however I guess I am having trouble explaining myself:

   +-------------------------------------------------+
   | Window 1                                          -- BX |
   +-------------------------------------------------+
   |                                                                 |
   |   +--------------------------------------+        |
   |   | Window 2                            -- BX|         |
   |   +--------------------------------------+        |
   |   |                                                   |        | 
   |   |                                                   |        |
   |   |                                                   |        |
   |   |                                   +---------+|        |
   |   |                                    |CANCEL ||        |
   |   |                                   +---------+|        |
   |   +---------------------------------------+       |
   +-------------------------------------------------+

Now, window 1 creates window 2 dynamically and a web page is loaded.  For purposes of argument lets say the user is asked for a password.  If the user does not want to continue, the user clicks on the Cancel Button.  If the page was running by itself, not in an iframe inside a window the routine would issue a self.close and all is done.  However, when I do that in this scenario the window 2 stays.  So how do I close window 2 from window 2.  I have tried calling a subroutine (e.g.  window.parent.runSomething("CLOSEME")  )  but I do not get an error and the winow just sits there.  The runSomething function is in the <head> section of the windows 1 program which dynamically built the second window.  I think the problem is with the IFrame but I really haven't been able to figure it out.

Once again thank you for your timely reply

Charlie           


Title: Re: Closing a Window
Post by: stworthy on October 10, 2014, 07:57:34 PM
You may need to explain what your window is. Is it a browser window or a easyui window? Posting some code snippets may be more appropriate.


Title: Re: Closing a Window
Post by: essco on October 10, 2014, 10:56:16 PM
Thank you for answering...

It is an Easy-UI window:

     <div id="xx" class="easyui-window" ......>
          <iframe scrolling="auto" frameborder="0"  src="http://....." style="width:100%;height:100%;"></iframe
     </div>

This was the only way I could figure to load an html page into a window.  Also these lines are generated in "real time" and appended to the parent window (also an easy-ui window).

Charlie


Title: Re: Closing a Window
Post by: stworthy on October 10, 2014, 11:54:33 PM
It is easy to load a html page into the window, just set the 'href' property.
Code:
<div id="xx" class="easyui-window" href="..." ......>
</div>

The window plugin extends from panel plugin, it has all the features defined in panel plugin. Please refer to this example http://www.jeasyui.com/demo/main/index.php?plugin=Panel&theme=default&dir=ltr&pitem=Load%20Content


Title: Re: Closing a Window
Post by: essco on October 11, 2014, 07:10:23 AM
Once again, thank you so much for your help....but...
Using the panel and refresh seems to work fine...but...
I cannot access any javascript functions in windows 2 it tells me


ReferenceError: ESSSMaybe is not defined

of course it is, and when I run the HTML not in a window, all is fined.

I am close, please continue to help

Charlie


Title: Re: Closing a Window
Post by: stworthy on October 12, 2014, 05:19:40 PM
By default, the panel only extracts the <body> of content page, the <head> will be discarded. To let your script functions to be loaded into a panel, please move the <script> tags to the <body>.


Title: Re: Closing a Window
Post by: essco on October 16, 2014, 04:46:10 PM
Thank you so much for your kind reply...

Moving scripts to the body section of a form becomes a cumbersome task, and negates loading a page not written by me.

Charlie

p.s. This is not meant to be argumentative just true.  I do not need a reply.  Consider this closed.