PDA

View Full Version : MessageBox.confirm on tab close



aj3423
28 Dec 2009, 4:00 AM
I've tried google "site:extjs.com close tab confirm" and tried all method I found, still no luck;


tab.on('beforeremove', function(tab, grid) {
if(tab.removeConfirmed){
delete tab.removeConfirmed;
return true;
}
var errMsgWdwGrp = new Ext.WindowGroup();
errMsgWdwGrp.zseed = 1000000;

var msg = Ext.Msg.confirm('confirm', 'close?', function(btn) {
if(btn == 'yes'){
tab.removeConfirmed = true;
//some code to remove the tab
}
});
msg.getDialog().manager = errMsgWdwGrp;
Ext.WindowMgr.bringToFront(msg.getDialog());
return false;
});

the message box always displays behind the tabpanel;
how can i solve this?
Thanks;

Condor
28 Dec 2009, 6:54 AM
It should probably be:

tab.on('beforeremove', function(tab, grid) {
if(tab.removeConfirmed){
delete tab.removeConfirmed;
return true;
}
var errMsgWdwGrp = new Ext.WindowGroup();
errMsgWdwGrp.zseed = 1000000;
var msg = Ext.Msg.confirm('confirm', 'close?', function(btn) {
if(btn == 'yes'){
tab.removeConfirmed = true;
tab.remove(grid);
}
});
msg.getDialog().manager = errMsgWdwGrp;
errMsgWdwGrp.bringToFront(msg.getDialog());
return false;
});

aj3423
8 Feb 2010, 8:52 PM
Thanks, but i found another problem, maybe not problem:)
when click on a 'close' button to close a tab, there are two events: mousedown and mouseup, and TabPanel handles the 'beforeclose' event at mousedown, so after i use MessageBox in the 'beforeclose', the 'close' button recieves a mouseup, and this brings the tabPanel to the front of MessageBox, which make the hole thing looks like the MessageBox displays behind the TabPanel,
i think it should handle beforeclose when mouseup, i traced into the code and did some override to fix this:

Ext.override(Ext.TabPanel, {
initEvents : function(){
Ext.TabPanel.superclass.initEvents.call(this);
this.mon(this.strip, {
scope: this,
//mousedown: this.onStripMouseDown, // origin code
mouseup: this.onStripMouseDown,
contextmenu: this.onStripContextMenu
});
if(this.enableTabScroll){
this.mon(this.strip, 'mousewheel', this.onWheel, this);
}
}
});
would this override cause some other errors?