【问题标题】:show message box ext window beforeclose event在关闭事件之前显示消息框扩展窗口
【发布时间】:2019-10-30 06:26:27
【问题描述】:

我想在用户单击 ext 窗口的 (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();
};

谢谢

【问题讨论】:

    标签: javascript extjs dom-events


    【解决方案1】:

    在您的 beforeclose 侦听器中返回 false 以停止触发关闭事件。

    【讨论】:

      【解决方案2】:

      这对我来说很好。看看

      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();   
          };
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-07-02
        • 1970-01-01
        • 2017-12-06
        • 1970-01-01
        • 2020-11-29
        • 2013-11-04
        • 1970-01-01
        相关资源
        最近更新 更多