Justin Liang
Justin Liang

Reputation: 211

EXT JS close pop up window

I have a pop up window without close button, so I have to refresh the page in order to close the pop up window. In this case, I wanna to add an button on the pop up window for closing.

Here is the js code:

function oseGetWIn(id, title, width, height)
{
    var win = Ext.create('Ext.window.Window', {
        id: id,
        name: id,
        title: title,
        width: width,
        height: height,
        closeAction:'destroy',
        autoScroll:'true',

    }); 
    return win; 
}

I tried to add the following, but no effect.

bbar: [
        {
          text: 'Close',
          handler: function () { this.up('.window').close(); }
         }
      ],

Upvotes: 2

Views: 14197

Answers (6)

olegtaranenko
olegtaranenko

Reputation: 3880

hmmm... still not answered? the solution is simple

var win = Ext.create('Ext.window.Window', {
        id: id,
        name: id,
        title: title,
        width: width,
        height: height,
        closeAction:'destroy',
        autoScroll:'true',
        closable:true,
        bbar:[{
            text:'Close',
            handler:function(bt){
                bt.up('window').close();
            }
        }]
    })

Upvotes: 1

muammertuzun
muammertuzun

Reputation: 123

This seems to me the simplest way

var wind = Ext.WindowManager.getActive();

if(wind){
     wind.close();
}

Upvotes: 0

Surya Prakash Tumma
Surya Prakash Tumma

Reputation: 2193

Try this in close handler

this.up().up().close(); or this.up().close();

Upvotes: -1

CD..
CD..

Reputation: 74176

This should work:

var win = Ext.create('Ext.window.Window', {
            title: 'test',
            width: 400,
            height: 200,
            bbar:[{
                text:'Close',
                handler: function(){
                    win.destroy();
                }
            }]
        })

working example: http://jsfiddle.net/RdVyz/

Upvotes: 1

Jacobian
Jacobian

Reputation: 10862

Try this

var win = Ext.create('Ext.window.Window', {
    id: id,
    name: id,
    title: title,
    width: width,
    height: height,
    closeAction:'destroy',
    autoScroll:'true',
    closable:true // add this attribute and you will get a close button on right top
});

EDIT: Now try this:

var win = Ext.create('Ext.window.Window', {
            id: id,
            name: id,
            title: title,
            width: width,
            height: height,
            closeAction:'destroy',
            autoScroll:'true',
            closable:true,
            bbar:[{
                text:'Close',
                handler:function(){
                    this.up('window').destroy();
                }
            }]
        })

Upvotes: 0

Evan Trimboli
Evan Trimboli

Reputation: 30092

The selector is incorrect, it should just be window, which will find the parent with a matching xtype.

Upvotes: 1

Related Questions