PDA

View Full Version : How to confirm window closing



Amadey
16 Jan 2013, 2:48 AM
Greetings,

I'm noob in JS and Ext. My first js 'hello world' was yesterday...

Well. The idea was to ask user if he really want to close window. The result is:



function confirm_close()
{
Ext.Msg.confirm('????','?? ????????????? ???? ?????????',

function(answer){

if (answer == 'yes'){

ras4window.destroy();
}

}

);
}


function window_on_create(){
ras4window=Ext.create('Ext.window.Window', {

title: '??????',

height: 200,

width: 400,

layout: 'fit',

listeners:{

beforeclose: function() {

confirm_close();

return false;

}

},


items: {
}

}).show();



Is there any better ways of doing this?

P.s. my english is bad. sorry.

Tim Toady
16 Jan 2013, 12:35 PM
That looks pretty good. I would probably organize the code differently, but the concept of returning false from beforeclose and showing a confirm dialog is correct.