How to close modal window extjs when clicking on mask?

前端 未结 4 1280
遇见更好的自我
遇见更好的自我 2021-02-05 16:19

If I create a modal window:

Ext.define(\'myWindow\', {
    extend: \'Ext.Container\',
    alias: \'widget.myWindow\',
    floating: true,
    modal: true,
    li         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 16:51

    I found adding a listener to the body and checking css classes felt a little hackey to me. You can actually override the private method _onMaskClick of Ext.ZIndexManager (see, completely not hackey). Which allows you to add your own configuration parameter (and even event) to all windows.

    Ext.define('MyApp.ux.ZIndexManager_maskClick', {
      override: 'Ext.ZIndexManager',
    
      _onMaskClick: function ()
      {
        if (this.front)
        {
          var allowed = this.front.fireEvent('maskclick', this.front, this.mask);
    
          if (allowed !== false && this.front.closeOnMaskClick)
            this.front.close();
        }
        return this.callParent(arguments);
      },
    });
    

提交回复
热议问题