View Full Version : Check if window already open

13 Feb 2011, 1:56 AM

I would like to open only one instance of window object simultaneously (if window already opened -> ignore action), moreover all fields in new window should be empty or predefined with default values.

In case of using closeAction: 'hide' and win.show() i can open window with empty fields, but number of opened windows can be unlimited.

Need advise. Thank you.

13 Feb 2011, 3:24 AM
function createYourWindow(paramWinId){
var yourWindow = someExtGetElement(paramWindowId) ;
if ( !yourWindow ){
// create your window here
yourWindow = new Ext.Window ...

is the simplest design pattern : a singleton...

13 Feb 2011, 3:50 AM
MyWindowUi = Ext.extend(Ext.Window, { ... });

Ext.onReady(function () {
var newOrderLink = Ext.get('new_order_link');
var newOrderForm;

newOrderForm = new MyWindowUi;

in this case i have one window but if fill window fields with some data than close window and open it again these fields contain previously entered data.
Is there any way to clear fields?

13 Feb 2011, 3:53 AM
i dont know... maybe play with stateful and autodestroy properties...

17 Oct 2013, 7:25 PM
The Button or component that you use to trigger the load of this window can be disabled as soon as the new window shows up. And later the button can be enabled before win.close();.
This way user wont be able to open another window, once a window is already open.