显示消息框分机窗口beforeclose事件(show message box ext window

2019-10-18 03:53发布

我想显示消息框分机窗口时,用户点击(X)按钮,并在消息框窗口的“确定”按钮将关闭。 我写的代码,但它首先关闭窗口比显示消息框。 下面是代码:

var assignReportFlag = 0;
var assignReportLoader = function(title,url){   
var panel = new Ext.FormPanel({
    id: 'arptLoader',
    height: 485,
    border: false,
    layout: 'fit',      
    autoScroll: true,
    method:'GET',
    waitMsg: 'Retrieving form data',
    waitTitle: 'Loading...',
    autoLoad: {url: url,scripts: true}
});

var cqok = new Ext.Button({
    text:'OK',
    id:'1',
    handler: function(){            
        if(assignReportFlag == 1){
            assignReportFlag = 0;
            Ext.MessageBox.alert('Status', 'Changes has been saved successfully',showResult);
        }else{
            assignReportWindow.close();         
        }           
    }
});

var assignReportWindow = new Ext.Window({       
    layout:'fit',
    title: title,       
    height:Ext.getBody().getViewSize().height - 60,
    width:Ext.getBody().getViewSize().width-20,
    closable: true,
    modal:true,
    resizable: false,
    autoScroll:true,
    plain: true,
    border: false,
    items: [panel],
    buttons: [cqok],
    listeners:{
        beforeclose:function(){
            if(assignReportFlag == 1){
                assignReportFlag = 0;
                Ext.MessageBox.alert('Status', 'Changes has been saved successfully',showResult);
            }else{
                assignReportWindow.destroy();           
            }
        }
    }
});

function showResult(btn){       
    assignReportWindow.destroy();   
};

assignReportWindow.show();
};

谢谢

Answer 1:

在您的beforeclose听众返回false停止被解雇的关闭事件。



Answer 2:

这工作正常me.Have看看

http://jsfiddle.net/DrjTS/266/

var cqok = new Ext.Button({
text:'OK',
id:'1',
handler: function(){            
        Ext.MessageBox.alert('Status', 'Changes has been saved successfully',showResult);
    }
 });

Ext.create('Ext.panel.Panel', {
title: 'Hello',
width: 200,
renderTo: Ext.getBody(),
items:[
        {
xtype:'button',
text:'SUBMIT',
            handler:function(thisobj)
            {
                Ext.create('Ext.window.Window', {
                id:'W',
                height: 200,
                width: 400,
                layout: 'fit',
                buttons: [cqok],
                listeners:{
                beforeclose:function(){
                            Ext.MessageBox.alert('Status', 'Changes has been saved');
                        }
                }    
                }).show();
            }
        }
       ]

    });

    function showResult(btn){       
    Ext.getCmp('W').destroy();   
    };


文章来源: show message box ext window beforeclose event