user1088984
user1088984

Reputation: 37

Why i can't show new Ext.Window twice

I have a html with one div and two scripts with Ext Js 3.4.0

<script type="text/javascript" src="js/listaBancos.js"></script>

The file listaBancos.js show a Grid with toolbar button in the divListaBancos, the first time i click the button "Agregar" and i see the Window declared in altaBanco.js.

==============Part of the grid in listaBancos.js============

 tbar:[{
    text:'Agregar',
    tooltip:'Agrega un banco',
    iconCls:'add',
    handler: agregaBanco
}]

function agregaBanco(){
var win =Ext.getCmp('myWin');
win.show();

}

==============Window declared in altaBanco.js================

var winAltaBanco = new Ext.Window({
    id     : 'myWin',
    height : 250,
    width  : 400,

});

When i close the window then click the button again the windows doesn't showed.

Can you help me ???

Upvotes: 0

Views: 1916

Answers (3)

Fatih Acet
Fatih Acet

Reputation: 29569

There is no need to make any trick, simply remove your window id. In ExtJS component ids must be unique.

Upvotes: 0

Varun Achar
Varun Achar

Reputation: 15109

The default close action of a windows is close, i.e., it destroys the component, hence it cannot be accessed using Ext.geCmp() again since it doesn't exist on the DOM anymore. To achieve what you want either set closeAction : hide or

var cmp = Ext.getCmp('myId');
if(!cmp)
{
cmp = new Ext.Window({
  id : 'myId'
});
}
cmp.show();

Prefer hiding to recreating.

Upvotes: 1

MMT
MMT

Reputation: 2216

Make sure in window config close action is set to hide.

closeAction:'hide'

check this

Upvotes: 0

Related Questions