1

I need to show an overlay on button click.To achieve this i have written the following code:-

 var miscButton = {
                xtype: 'button',
                iconCls: 'star',
                iconMask: true,
                width: 60,
                margin: '0 0 0 15',
                handler: function(){

                  fPanel.showBy(this);
                }
        };



       var fPanel = Ext.create('Ext.Panel',{
                    layout: 'vbox',
                    width: 150,
                    height: 300,
                    style: 'background-color: #5E99CC;',
                    items: [
                            {
                               xtype: 'list',
                               flex: 1,
                               itemTpl: '{item}',
                               data: [
                                          {item: 'item1'},
                                          {item: 'item2'},
                                          {item: 'item3'},
                                          {item: 'item4'},
                                          {item: 'item5'},
                                          {item: 'item6'},
                                          {item: 'item7'},
                                          {item: 'item8'},
                                          {item: 'item9'},
                                          {item: 'item10'},
                                          {item: 'item11'},
                                          {item: 'item12'},
                               ]                    
                            }
                    ]

        });

When i click on button it is showing the overlay perfectly but after another click it is not able to hide the overlay,like given in the link http://docs.sencha.com/touch/2-0/#!/example/overlays.

I dont understand what is the problem with showBy(). Please help me to solve this problem.

Thanx in advance.

Saurabh Gokhale
  • 53,625
  • 36
  • 139
  • 164
himanshu
  • 1,990
  • 3
  • 18
  • 36

2 Answers2

1

To hide an overlay panel, simply make a call

fPanel.hide();

FYI, if you want to be able to hide the panel on mask tap, use this property of panel,

modal: true,
hideOnMaskTap: true
Saurabh Gokhale
  • 53,625
  • 36
  • 139
  • 164
0

This seems to be a quite "ugly" work-around but it does work:

handler: function(){
  fPanel.setHidden(!fPanel.getHidden());
}

There might be some typing mistakes in that snippet but my idea is to toggle your panel's hidden property

Thiem Nguyen
  • 6,345
  • 7
  • 30
  • 50