PDA

View Full Version : How to hide a widget window?



philr
4 Oct 2012, 12:50 PM
Hi all,

I have a widget window that needs to be hidden, but I haven't found a solution which works.
Can you guys provide some insight?

This is my defined widget window below:



Ext.define('add_window', {
extend: 'Ext.window.Window',
alias: 'widget.add_window',
title: 'Add Window',
closeAction: 'hide',
floating: true,
items: [{
xtype: 'panel',
border: false,
width: 1100,
height: 650,
html: "<iframe src='../add_data_window/index.html'></iframe>"
}],
listeners:
{
beforeclose: function(win)
{
win.hide();
}
}
};

Thank you very much!

Tim Toady
4 Oct 2012, 1:25 PM
I'm not sure I understand what you are asking. You can close the window by clicking the X button. If you wanted an actual close button you would have a button on the windows footer that in its handler got a window reference and called hide(). You currently are trying to call hide in the beforeclose listener which doesn't make sense.

philr
4 Oct 2012, 1:52 PM
Perhaps I should provide a bit more detail.

The widget window is being opened by another 'parent' window.
The contents of the iframe is an entry form which get submitted to a remote server.

So I have within the widget window an entry from with the submit button.
On the server successful response, I like to close the widget window, but from the iframe within it.

I can reference the widget window from the iframe within it by using Ext.widget('add_window').close();

But that doesn't close the window. It does however trigger the beforeclose event.

That's why I used the beforeclose listener. My only obstacle at this point is how to hide the window.

Tim Toady
4 Oct 2012, 1:59 PM
Ext.widget creates a new window. It does not get a reference to it. So you are basically creating and closing a new window. I strongly recommend not putting your form in an iframe. It will be easier for you to get a reference to the existing window and call hide or close.